11#ifndef PROTO_FUZZER_WEBSOCKET_MOCK_SERVER_H_
12#define PROTO_FUZZER_WEBSOCKET_MOCK_SERVER_H_
21#include "curl_fuzzer.pb.h"
25namespace proto_fuzzer {
42 void Install(CURL* easy)
override;
44 void SetFrames(std::vector<std::string> frames);
56 const std::string&
PeekChunk(std::size_t index)
const;
58 bool PushRawBytes(
const unsigned char* data, std::size_t size);
70 struct curl_sockaddr* address =
nullptr)
override;
71 void RunLoop(CURLM* multi, CURL* easy,
const curl::fuzzer::proto::Scenario& scenario)
override;
80 std::vector<std::string> frames_;
81 std::size_t next_chunk_;
82 bool manual_delivery_;
86 std::size_t manual_received_bytes_;
87 std::string ws_request_buffer_;
Receives bytes after any transport decoding.
std::size_t remaining_chunks() const
bool TryAdvanceHandshake(bool *made_progress=nullptr)
Drive the WebSocket opening handshake: read whatever curl has written so far, and once we've seen the...
bool PushRawBytes(const unsigned char *data, std::size_t size)
Push raw bytes onto the server fd.
void ObserveIncomingData(const unsigned char *data, std::size_t size) override
Collect application bytes consumed by the active transport.
bool DeliverNextChunk()
Push the next queued frame when curl is ready.
WebSocketMockServer()
Construct an idle WebSocketMockServer with no queued frames.
CURL * easy_handle() const
void SetFrames(std::vector< std::string > frames)
Queue RFC 6455 wire-byte chunks to emit once the handshake has completed.
virtual void FlushTransport()
Flush application writes when the carrier queues them.
const std::string & PeekChunk(std::size_t index) const
Access a pending chunk without consuming it.
bool manual_delivery() const
void ConsumeChunk()
Advance the pending-chunk cursor by one. No-op when no chunks remain.
void RunLoop(CURLM *multi, CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override
Seed the mock from the scenario, then run the perform loop.
bool handshake_sent() const
bool has_more_chunks() const
void SetManualDelivery(bool manual)
Toggle streaming (false, default) vs manual (true) chunk delivery.
void Install(CURL *easy) override
Install the shared socket trampolines via the base, then layer a WebSocket-aware WRITEFUNCTION / HEAD...
~WebSocketMockServer() override
Default destructor; the owned MockConnection (if any) cleans up its socketpair.
bool ws_probe_fired() const
Return the one-shot probe gate.
std::size_t manual_received_bytes() const
curl_socket_t HandleOpenSocket(curlsocktype purpose=CURLSOCKTYPE_IPCXN, struct curl_sockaddr *address=nullptr) override
Called by the OPENSOCKETFUNCTION trampoline in the base class.
virtual std::size_t DrainHandshakeData()
Consume the plaintext Upgrade request without applying DrainIncoming's backpressure limit.
void ObserveState() override
Retain protocol outcomes in coverage and introspector builds.
virtual std::unique_ptr< MockConnection > CreateConnection()
Construct the transport used for the WebSocket exchange.
void MarkWsProbeFired()
Flip the one-shot gate closed.
MockConnection and MockServer — the in-process peer that feeds canned response bytes to libcurl over ...
MockServerBase — common plumbing shared by every protocol-specific mock server.
bool ScenarioRequestsManualWsDrive(const curl::fuzzer::proto::Scenario &scenario)
Mirror the sequential CURLOPT_CONNECT_ONLY setopts applied by ApplyScenarioOptions.