curl-fuzzer C++ reference
Loading...
Searching...
No Matches
proto_fuzzer::HttpTransportMockServer Class Referencefinal

Drives ordinary HTTP response scripts through one of three fixed routing shapes: an absolute-form forward proxy request, an HTTP/1.1 CONNECT tunnel, or an abstract Unix-domain socket. More...

#include <http_transport_mock_server.h>

Inheritance diagram for proto_fuzzer::HttpTransportMockServer:
proto_fuzzer::MockServer proto_fuzzer::IncomingDataObserver proto_fuzzer::MockServerBase

Public Member Functions

 HttpTransportMockServer (curl::fuzzer::proto::HttpTransportMode mode, bool haproxy_protocol)
 Construct an idle transport peer for one policy-normalized mode.
void ObserveState () override
 Retain protocol outcomes in coverage and introspector builds.
void Install (CURL *easy) override
 Install socket callbacks followed by the fixed routing options.
const std::string & client_transcript () const
Public Member Functions inherited from proto_fuzzer::MockServer
 MockServer (MultiDrivePolicy drive_policy=MultiDrivePolicy::kPerform)
 Construct an idle MockServer with no scripted responses or open peers.
 ~MockServer () override
 Default destructor; current and previous MockConnections clean up their server-side descriptors only after curl has been removed from the multi.
void SetScripts (const curl::fuzzer::proto::Scenario &scenario)
 Build the complete borrowed script table before entering curl.
void SetKeepConnectionsOpen (bool keep_open)
 Keep completed response sockets writable instead of half-closing them.
CURLcode DriveEasyScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario, bool use_events=false) override
 Preload all bounded response bytes from inside OPENSOCKETFUNCTION, where the mock still owns both socketpair ends, and half-close the peer when the preload finishes.
ConnectOnlyRunStats DriveConnectOnlyScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override
 Establish only the HTTP transport, then pass bounded application bytes through curl's public direct-I/O wrappers.
bool DeliverNextChunk ()
 Push the next queued chunk.
bool has_more_chunks () const
bool ServiceConnections ()
 Service one deterministic application event-loop turn by draining all available request bytes and releasing at most one response chunk.
std::size_t opened_connection_count () const
 Report how many peer sockets curl opened during the current script run.
Public Member Functions inherited from proto_fuzzer::MockServerBase
virtual ~MockServerBase ()
 Out-of-line destructor so MockConnection can stay forward-declared in the base header (its complete type is only needed where unique_ptr is instantiated for destruction).
virtual void ConfigureRequestData (ScenarioRequestData *request_data)
 Bind protocol-specific work to the request-data callbacks after their per-scenario state has been constructed.
CURLcode DriveScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario)
 Run 'scenario' to completion on 'easy': allocate a multi, attach 'easy', delegate protocol-specific work to RunLoop, consume its completion message, and clean up.
void SetMultiObserver (MultiObserver observer)
 Register an observer invoked with the live multi handle after 'easy' is attached and before the drive loop starts.
MockConnection * connection ()

Protected Member Functions

std::unique_ptr< MockConnection > CreateConnection () override
 Create one socketpair and attach the transcript observer.
void ObserveIncomingData (const unsigned char *data, std::size_t size) override
 Retain a bounded raw transcript for strict request-shape tests.
bool SupportsRepeatedPollsetProbe () const override
 The request-aware peer drains every bounded perform turn, so repeated zero-timeout poll probes cannot strand client output.
Protected Member Functions inherited from proto_fuzzer::MockServer
void ResetConnections ()
 Release all current and retired socketpairs before resetting transport- specific state.
virtual void ObserveActiveTransfer (CURL *easy)
 Observe curl while its connection filters are still attached.
curl_socket_t HandleOpenSocket (curlsocktype purpose=CURLSOCKTYPE_IPCXN, struct curl_sockaddr *address=nullptr) override
 Called by the OPENSOCKETFUNCTION trampoline in the base class.
void RunLoop (CURLM *multi, CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override
 Seed the mock from the scenario, then drive the perform loop until curl is done or a deterministic operation/idle budget is hit.
Protected Member Functions inherited from proto_fuzzer::MockServerBase
 MockServerBase (MultiDrivePolicy drive_policy=MultiDrivePolicy::kPerform)
 Construct an empty base instance with a fixed multi-drive policy.
virtual void HandleDetachedMulti (CurlMultiPtr multi)
 Dispose of or retain the multi after its easy handle has been removed.
virtual SocketSetupDisposition GetSocketSetupDisposition (curl_socket_t curlfd, curlsocktype purpose) const
 Describe the socket returned by HandleOpenSocket without issuing native descriptor queries.
MultiSocketDriver * multi_socket_driver ()
 Expose the callback state installed for the current socket-action drive.
std::size_t additional_handle_cleanup_count () const
void ResumeResponseIfRequested (CURL *easy)
 Resume receive-side callback output at one bounded drive boundary when the dedicated API plan requested it.
void ApplyPendingBackpressure ()
 Apply the BackpressureConfig cached by DriveScenario to the new connection_.

Additional Inherited Members

Public Types inherited from proto_fuzzer::MockServerBase
using MultiObserver = std::function<void(CURLM*)>
 Callback type used to publish the driving multi handle to observers.
Static Protected Member Functions inherited from proto_fuzzer::MockServerBase
static int WaitOnMultiFdset (CURLM *multi, CURLMcode *rc)
 Wait on curl's fdset with a short timeout.
static void ProbeMultiPollset (CURLM *multi)
 Ask curl to construct and inspect its connection-filter pollset without waiting.
static bool MultiPollsetWantsWrite (CURLM *multi, curl_socket_t socket)
 Inspect one socket's current writable interest through curl's public multi fdset API.
static bool UsesTimedDrive (const curl::fuzzer::proto::Scenario &scenario)
 Treat a non-default BackpressureConfig as an explicit request for the slower, timed drive policy.
Protected Attributes inherited from proto_fuzzer::MockServerBase
std::unique_ptr< MockConnection > connection_
 The per-scenario MockConnection, lazily created by HandleOpenSocket().
int pending_recv_buf_bytes_
 Cached SO_RCVBUF/SO_SNDBUF setting in bytes.
std::size_t pending_drain_limit_
 Cached per-call DrainIncoming byte budget.
MultiSocketDriver * multi_socket_driver_
 Non-owning pointer into DriveScenario's stack.
std::size_t additional_handle_cleanup_count_
 Number of application-created handles, excluding the caller's parent, successfully removed from the current multi and cleaned up.
bool resume_response_
 True only for an API-plan multi drive with its one-shot write callback.
MultiObserver multi_observer_
 Observer receiving the live multi handle at the start of a drive.
Static Protected Attributes inherited from proto_fuzzer::MockServerBase
static constexpr int kMaxDriveIterations = 512
 Hard operation budget for one scenario.
static constexpr int kMaxIdleIterations = 8
 Consecutive no-progress budget for ordinary scenarios.
static constexpr int kMaxTimedIdleIterations = 256
 Explicit backpressure scenarios get a larger idle budget and may use the short timed wait above.

Detailed Description

Drives ordinary HTTP response scripts through one of three fixed routing shapes: an absolute-form forward proxy request, an HTTP/1.1 CONNECT tunnel, or an abstract Unix-domain socket.

Every outbound socket is replaced by the inherited socketpair callback, and no fuzzed byte selects a destination.

Definition at line 27 of file http_transport_mock_server.h.

Constructor & Destructor Documentation

◆ HttpTransportMockServer()

proto_fuzzer::HttpTransportMockServer::HttpTransportMockServer ( curl::fuzzer::proto::HttpTransportMode mode,
bool haproxy_protocol )

Construct an idle transport peer for one policy-normalized mode.

Parameters
modeFixed proxy or Unix-domain route to install.
haproxy_protocolWhether CONNECT carries a fixed HAProxy v1 prefix.

Definition at line 31 of file http_transport_mock_server.cc.

Member Function Documentation

◆ client_transcript()

const std::string & proto_fuzzer::HttpTransportMockServer::client_transcript ( ) const
Returns
Bounded client bytes observed during the latest transfer.

Definition at line 77 of file http_transport_mock_server.cc.

◆ CreateConnection()

std::unique_ptr< MockConnection > proto_fuzzer::HttpTransportMockServer::CreateConnection ( )
overrideprotectedvirtual

Create one socketpair and attach the transcript observer.

Returns
Fresh in-process stream connection.

Reimplemented from proto_fuzzer::MockServer.

Definition at line 81 of file http_transport_mock_server.cc.

◆ Install()

void proto_fuzzer::HttpTransportMockServer::Install ( CURL * easy)
overridevirtual

Install socket callbacks followed by the fixed routing options.

The scenario's scalar option allowlist contains no routing options, so these settings remain authoritative when the common runner applies mutations.

Parameters
easyEasy handle to configure.

Reimplemented from proto_fuzzer::MockServerBase.

Definition at line 38 of file http_transport_mock_server.cc.

◆ ObserveIncomingData()

void proto_fuzzer::HttpTransportMockServer::ObserveIncomingData ( const unsigned char * data,
std::size_t size )
overrideprotectedvirtual

Retain a bounded raw transcript for strict request-shape tests.

Parameters
dataFirst byte in this drained fragment.
sizeNumber of bytes available at data.

Implements proto_fuzzer::IncomingDataObserver.

Definition at line 95 of file http_transport_mock_server.cc.

◆ SupportsRepeatedPollsetProbe()

bool proto_fuzzer::HttpTransportMockServer::SupportsRepeatedPollsetProbe ( ) const
overrideprotectedvirtual

The request-aware peer drains every bounded perform turn, so repeated zero-timeout poll probes cannot strand client output.

Returns
true for all fixed transport modes.

Reimplemented from proto_fuzzer::MockServer.

Definition at line 90 of file http_transport_mock_server.cc.


The documentation for this class was generated from the following files: