curl-fuzzer C++ reference
Loading...
Searching...
No Matches
proto_fuzzer::ScenarioRequestData Class Reference

Builds HTTP headers or TELNET options, MIME state, and upload callbacks whose storage or userdata libcurl retains by pointer. More...

#include <request_data.h>

Public Member Functions

 ScenarioRequestData (CURL *easy, const curl::fuzzer::proto::Scenario &scenario, bool apply_resolve_entries=false)
 Construct and apply the protocol-specific pointer-valued fields in scenario to easy.
 ScenarioRequestData (CURL *easy, curl::fuzzer::proto::Scenario &&scenario, bool apply_resolve_entries=false)=delete
 A temporary Scenario cannot outlive the upload view retained for curl.
 ~ScenarioRequestData ()
 Detach pointer options/callbacks while the easy handle is valid, then release request allocations.
const RequestBuildStats & stats () const
 Return resource counts after caps and allocation failures were applied, without exposing or transferring the owned curl pointers themselves.
const UploadScriptState & upload_state () const
 Return the callback state retained for the complete drive.
bool upload_callbacks_installed () const
 Return whether this scenario needed raw upload callbacks.
bool resolve_entries_ready () const
 Return whether resolver-only slist construction installed its mandatory final loopback mapping.
void SetBeforeUploadReadCallback (UploadScriptState::BeforeReadCallback callback, void *userdata)
 Arrange protocol-specific work immediately before every upload read.

Detailed Description

Builds HTTP headers or TELNET options, MIME state, and upload callbacks whose storage or userdata libcurl retains by pointer.

Keeping them in one scope makes their lifetime visibly encompass the complete multi-handle drive rather than relying on setopt copying data that its API explicitly does not copy.

Definition at line 112 of file request_data.h.

Constructor & Destructor Documentation

◆ ScenarioRequestData()

proto_fuzzer::ScenarioRequestData::ScenarioRequestData ( CURL * easy,
const curl::fuzzer::proto::Scenario & scenario,
bool apply_resolve_entries = false )

Construct and apply the protocol-specific pointer-valued fields in scenario to easy.

Setup errors are deliberately non-fatal: malformed or partially allocated scenarios should still exercise whatever curl state was built. easy must remain alive until this object is destroyed, because cleanup first detaches the pointers from the handle and only then frees them.

Parameters
easyEasy handle that will perform this scenario.
scenarioSource headers/TELNET options, optional MIME body, and upload script.
apply_resolve_entriesWhether to install the scenario's bounded resolver mappings plus the mandatory loopback mapping.

Definition at line 483 of file request_data.cc.

◆ ~ScenarioRequestData()

proto_fuzzer::ScenarioRequestData::~ScenarioRequestData ( )

Detach pointer options/callbacks while the easy handle is valid, then release request allocations.

libcurl does not copy headers, MIME roots, or callback userdata, so releasing any one before the mock drive ends would create a use-after-free; relying on easy cleanup to own header/MIME allocations would instead leak iterations.

Definition at line 574 of file request_data.cc.

Member Function Documentation

◆ resolve_entries_ready()

bool proto_fuzzer::ScenarioRequestData::resolve_entries_ready ( ) const

Return whether resolver-only slist construction installed its mandatory final loopback mapping.

Ordinary lanes always report true.

Returns
True when the resolver mapping is ready for the transfer.

Definition at line 626 of file request_data.cc.

◆ SetBeforeUploadReadCallback()

void proto_fuzzer::ScenarioRequestData::SetBeforeUploadReadCallback ( UploadScriptState::BeforeReadCallback callback,
void * userdata )

Arrange protocol-specific work immediately before every upload read.

This is intentionally a narrow callback seam rather than exposing curl's retained READFUNCTION userdata or the mutable upload cursor.

Parameters
callbackFunction to invoke, or nullptr to clear the hook.
userdataBorrowed pointer passed to callback.

Definition at line 633 of file request_data.cc.

◆ stats()

const RequestBuildStats & proto_fuzzer::ScenarioRequestData::stats ( ) const

Return resource counts after caps and allocation failures were applied, without exposing or transferring the owned curl pointers themselves.

Returns
Immutable construction statistics.

Definition at line 610 of file request_data.cc.

◆ upload_callbacks_installed()

bool proto_fuzzer::ScenarioRequestData::upload_callbacks_installed ( ) const

Return whether this scenario needed raw upload callbacks.

Exposing the decision lets ownership tests ensure ordinary requests avoid redundant setopt/teardown work without exposing either userdata pointer.

Returns
True when read and seek callbacks were attached to the handle.

Definition at line 621 of file request_data.cc.

◆ upload_state()

const UploadScriptState & proto_fuzzer::ScenarioRequestData::upload_state ( ) const

Return the callback state retained for the complete drive.

This is mainly useful to ownership tests; the runner itself lets libcurl mutate it.

Returns
Immutable upload state.

Definition at line 615 of file request_data.cc.


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