35 }
catch (
const std::runtime_error&) {
41 (void)http_request.
GetURI();
52 const std::string body = http_request.
ReadBody();
53 const auto transfer_encoding = http_request.
GetHeader(
"Transfer-Encoding");
54 const auto content_length = http_request.
GetHeader(
"Content-Length");
55 if (transfer_encoding &&
ToLower(*transfer_encoding) ==
"chunked") {
58 }
else if (content_length) {
60 const auto parsed_length{ToIntegral<uint64_t>(*content_length)};
62 assert(body.size() == *parsed_length);
std::string ConsumeRandomLengthString(size_t max_length)
void WriteHeader(std::string &&hdr, std::string &&value)
std::string GetURI() const
bool LoadHeaders(util::LineReader &reader)
bool LoadControlData(util::LineReader &reader)
Methods that attempt to parse HTTP request fields line-by-line from a receive buffer.
std::optional< std::string > GetHeader(std::string_view hdr) const
HTTPRequestMethod GetRequestMethod() const
std::string ReadBody() const
bool LoadBody(util::LineReader &reader)
std::string_view RequestMethodString(HTTPRequestMethod m)
HTTP request method as string - use for logging only.
FUZZ_TARGET(http_request)
constexpr uint64_t MAX_BODY_SIZE
Maximum size of an HTTP request body received from a client.
constexpr size_t MAX_HEADERS_SIZE
Maximum size of each headers line in an HTTP request, also the maximum size of all headers total.
std::string ToLower(std::string_view str)
Returns the lowercase equivalent of the given string.
FuzzedDataProvider & fuzzed_data_provider