curl-fuzzer C++ reference
Loading...
Searching...
No Matches
http_transport_mock_server.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3 *
4 * SPDX-License-Identifier: curl
5 */
6
9
10#ifndef PROTO_FUZZER_HTTP_TRANSPORT_MOCK_SERVER_H_
11#define PROTO_FUZZER_HTTP_TRANSPORT_MOCK_SERVER_H_
12
13#include <cstddef>
14#include <memory>
15#include <string>
16
17#include "curl_fuzzer.pb.h"
20
21namespace proto_fuzzer {
22
28 public:
29 HttpTransportMockServer(curl::fuzzer::proto::HttpTransportMode mode, bool haproxy_protocol);
30 ~HttpTransportMockServer() override = default;
31
32 void ObserveState() override;
33
35 HttpTransportMockServer& operator=(const HttpTransportMockServer&) = delete;
36
37 void Install(CURL* easy) override;
38
39 const std::string& client_transcript() const;
40
41 protected:
42 std::unique_ptr<MockConnection> CreateConnection() override;
43
44 void ObserveIncomingData(const unsigned char* data, std::size_t size) override;
45
46 bool SupportsRepeatedPollsetProbe() const override;
47
48 private:
49 static constexpr std::size_t kMaxTranscriptBytes = 64 * 1024;
50
51 curl::fuzzer::proto::HttpTransportMode mode_;
52 bool haproxy_protocol_;
53 std::string client_transcript_;
54};
55
56} // namespace proto_fuzzer
57
58#endif // PROTO_FUZZER_HTTP_TRANSPORT_MOCK_SERVER_H_
std::unique_ptr< MockConnection > CreateConnection() override
Create one socketpair and attach the transcript observer.
bool SupportsRepeatedPollsetProbe() const override
The request-aware peer drains every bounded perform turn, so repeated zero-timeout poll probes cannot...
void ObserveState() override
Retain protocol outcomes in coverage and introspector builds.
void ObserveIncomingData(const unsigned char *data, std::size_t size) override
Retain a bounded raw transcript for strict request-shape tests.
HttpTransportMockServer(curl::fuzzer::proto::HttpTransportMode mode, bool haproxy_protocol)
Construct an idle transport peer for one policy-normalized mode.
void Install(CURL *easy) override
Install socket callbacks followed by the fixed routing options.
Receives bytes after any transport decoding.
MockServer(MultiDrivePolicy drive_policy=MultiDrivePolicy::kPerform)
Construct an idle MockServer with no scripted responses or open peers.
Optional observer for application bytes consumed by mock peers.
MockConnection and MockServer — the in-process peer that feeds canned response bytes to libcurl over ...