| 69 | } |
| 70 | |
| 71 | void HTTPServerRequest::readRequest(ReadBuffer & in) |
| 72 | { |
| 73 | char ch; |
| 74 | std::string method; |
| 75 | std::string uri; |
| 76 | std::string version; |
| 77 | |
| 78 | method.reserve(16); |
| 79 | uri.reserve(64); |
| 80 | version.reserve(16); |
| 81 | |
| 82 | if (in.eof()) |
| 83 | throw Poco::Net::NoMessageException(); |
| 84 | |
| 85 | skipWhitespaceIfAny(in); |
| 86 | |
| 87 | if (in.eof()) |
| 88 | throw Poco::Net::MessageException("No HTTP request header"); |
| 89 | |
| 90 | while (in.read(ch) && !Poco::Ascii::isSpace(ch) && method.size() <= MAX_METHOD_LENGTH) |
| 91 | method += ch; |
| 92 | |
| 93 | if (method.size() > MAX_METHOD_LENGTH) |
| 94 | throw Poco::Net::MessageException("HTTP request method invalid or too long"); |
| 95 | |
| 96 | skipWhitespaceIfAny(in); |
| 97 | |
| 98 | while (in.read(ch) && !Poco::Ascii::isSpace(ch) && uri.size() <= max_uri_size) |
| 99 | uri += ch; |
| 100 | |
| 101 | if (uri.size() > max_uri_size) |
| 102 | throw Poco::Net::MessageException("HTTP request URI invalid or too long"); |
| 103 | |
| 104 | skipWhitespaceIfAny(in); |
| 105 | |
| 106 | while (in.read(ch) && !Poco::Ascii::isSpace(ch) && version.size() <= MAX_VERSION_LENGTH) |
| 107 | version += ch; |
| 108 | |
| 109 | if (version.size() > MAX_VERSION_LENGTH) |
| 110 | throw Poco::Net::MessageException("Invalid HTTP version string"); |
| 111 | |
| 112 | // since HTTP always use Windows-style EOL '\r\n' we always can safely skip to '\n' |
| 113 | |
| 114 | skipToNextLineOrEOF(in); |
| 115 | |
| 116 | readHeaders(*this, in, max_fields_number, max_field_name_size, max_field_value_size); |
| 117 | |
| 118 | skipToNextLineOrEOF(in); |
| 119 | |
| 120 | setMethod(method); |
| 121 | setURI(uri); |
| 122 | setVersion(version); |
| 123 | } |
| 124 | |
| 125 | } |
nothing calls this directly
no test coverage detected