32 const std::string body{req.
ReadBody()};
55 }
catch (
const std::runtime_error&) {
81 case HTTPRequest::State::Init:
return 0;
82 case HTTPRequest::State::NeedsHeaders:
return 1;
83 case HTTPRequest::State::NeedsBody:
return 2;
84 case HTTPRequest::State::Complete:
return 3;
85 case HTTPRequest::State::Error:
return 4;
95 bool operator==(
const ParsedRequest&)
const =
default;
99 std::vector<ParsedRequest> requests;
101 std::string remainder;
107void Drain(
const std::shared_ptr<FuzzClient>&
client, RunResult& out)
128 assert(
cur->GetState() != HTTPRequest::State::Complete);
130 out.last_state =
cur->GetState();
131 if (
cur->GetState() == HTTPRequest::State::Error)
out.errored =
true;
151 out.last_state = HTTPRequest::State::Init;
170 auto client{std::make_shared<FuzzClient>()};
180 auto client{std::make_shared<FuzzClient>()};
#define Assert(val)
Identity function.
A combination of a network address (CNetAddr) and a (TCP) port.
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
Helper to initialize the global MockableSteadyClock, let a duration elapse, and reset it after use in...
std::string ConsumeRandomLengthString(size_t max_length)
T ConsumeIntegralInRange(T min, T max)
std::string & MutateRecvBuffer()
Used for tests.
static std::unique_ptr< HTTPRequest > TryReadRequest(const std::shared_ptr< HTTPRemoteClient > &client) EXCLUSIVE_LOCKS_REQUIRED(!client -> m_send_mutex)
Try to read an HTTPRequest from a client's receive buffer.
void Receive() EXCLUSIVE_LOCKS_REQUIRED(!m_sock_mutex)
std::string GetURI() const
std::optional< std::string > GetHeader(std::string_view hdr) const
HTTPRequestMethod GetRequestMethod() const
std::string ReadBody() const
void WriteReply(HTTPStatusCode status, std::span< const std::byte > reply_body={})
A mocked Sock alternative that succeeds on all operations.
std::string_view RequestMethodString(HTTPRequestMethod m)
HTTP request method as string - use for logging only.
std::unique_ptr< ProxyClient< messages::FooInterface > > client
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.
bool operator==(const CNetAddr &a, const CNetAddr &b)
FuzzedDataProvider provider
std::string ToLower(std::string_view str)
Returns the lowercase equivalent of the given string.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider