Kurlyk
Loading...
Searching...
No Matches
kurlyk::HttpRequest Class Reference

Represents an HTTP request configuration. More...

#include <HttpRequest.hpp>

Public Member Functions

void set_url (const std::string &host, const std::string &path, const std::string &query=std::string())
 Sets the request URL with base URL, path, and optional query parameters.
void set_url (const std::string &host, const std::string &path, const QueryParams &query)
 Sets the request URL with base URL, path, and query parameters.
void set_url (const std::string &url, const QueryParams &query)
 Sets the request URL and appends optional query parameters.
void set_accept_encoding (bool identity=false, bool deflate=false, bool gzip=false, bool brotli=false)
 Sets the Accept-Encoding header with optional encoding types.
void set_accept_language (const std::string &value)
 Sets the Accept-Language header value.
void set_content_type (const std::string &value)
 Sets the Content-Type header value.
void set_origin (const std::string &value)
 Sets the Origin header value.
void set_referer (const std::string &value)
 Sets the Referer header value.
void set_proxy (const std::string &ip, int port)
 Sets the proxy server address.
void set_proxy (const std::string &ip, int port, ProxyType type)
 Sets the proxy server address.
void set_proxy (const std::string &ip, int port, const std::string &username, const std::string &password, ProxyType type=ProxyType::PROXY_HTTP)
 Sets the proxy server address with authentication details.
void set_proxy_server (const std::string &server)
 Sets the proxy server address.
void set_proxy_auth (const std::string &auth)
 Sets the proxy authentication credentials.
void set_proxy_type (ProxyType type)
 Sets the proxy type.
void set_proxy_auth (const std::string &username, const std::string &password)
 Sets proxy authentication credentials.
void set_retry_attempts (long retry_attempts, long retry_delay_ms)
 Sets the number of retry attempts and delay before retrying.
void add_valid_status (long status)
 Adds a single valid HTTP status code.
void set_valid_statuses (const std::set< long > &statuses)
 Sets the valid HTTP status codes, replacing any existing values.
void clear_valid_statuses ()
 Clears all valid status codes.
void set_user_agent (const std::string &user_agent)
 Sets the User-Agent header.
void set_cookie (const std::string &cookie)
 Sets the cookie data.
void set_cert_file (const std::string &cert_file)
 Sets the client certificate file path.
void set_ca_file (const std::string &ca_file)
 Sets the path to the CA certificate file.
void set_timeout (long timeout)
 Sets the request timeout.
void set_connect_timeout (long connect_timeout)
 Sets the connection timeout.
void set_streaming (bool streaming)
 Enables or disables intermediate callbacks for response body chunks.
void set_verbose (bool verbose)
 Enables or disables verbose mode.
void set_debug_header (bool debug_header)
 Enables or disables debugging headers in output.

Public Attributes

uint64_t request_id = 0
 Unique ID of this concrete HTTP request.
uint64_t group_id = 0
 ID shared by related requests, for example all requests created by one HttpClient.
Headers headers
 HTTP request headers.
std::string url
 Full request URL.
std::string method = "GET"
 HTTP request method (e.g., "GET", "POST").
std::string content
 Data payload for the request.
std::string user_agent
 User-Agent header.
std::string accept_encoding
 Accept-Encoding header.
std::string cookie_file
 Path to the cookie file; if empty, cookies are not saved.
std::string cookie
 Cookie data as a string.
std::string cert_file
 Path to the client certificate file.
std::string key_file
 Path to the private key for the client certificate.
std::string ca_file
 Path to the CA certificate file.
std::string ca_path
 Path to a directory containing CA certificates.
std::string proxy_server
 Proxy address in <ip:port> format.
std::string proxy_auth
 Proxy authentication in <username:password> format.
ProxyType proxy_type = ProxyType::PROXY_HTTP
 Proxy type (e.g., HTTP, SOCKS5).
bool proxy_tunnel = true
 Enable proxy tunneling.
std::string interface_name
 Network interface name to use for the request.
bool use_interface = false
 Enable the specified network interface.
bool follow_location = true
 Automatically follow HTTP redirects.
long max_redirects = 10
 Maximum allowed redirects.
bool auto_referer = false
 Automatically set Referer header.
bool head_only = false
 If true, does not download the response body (HEAD-like behavior).
bool streaming = false
 Enable intermediate callbacks for response body chunks.
long timeout = 30
 Request timeout in seconds.
long connect_timeout = 10
 Connection timeout in seconds.
HttpRateLimitHandlePtr general_rate_limit
 General rate limit handle.
HttpRateLimitHandlePtr specific_rate_limit
 Specific rate limit handle.
std::string general_rate_limit_key
 Key used to separate general rate limit state; empty means default shared state.
std::string specific_rate_limit_key
 Key used to separate specific rate limit state; empty means default shared state.
std::set< long > valid_statuses = {200}
 Set of valid HTTP response status codes.
long retry_attempts = 0
 Number of retry attempts in case of failure.
long retry_delay_ms = 0
 Delay between retry attempts in milliseconds.
bool clear_cookie_file = false
 Flag to clear the cookie file at the start of the request.
bool verbose = false
 Enable verbose output (CURLOPT_VERBOSE).
bool debug_header = false
 Include headers in debug output (CURLOPT_HEADER).

Detailed Description

Represents an HTTP request configuration.

HttpRequest stores parameters for an HTTP request, including headers, URL, method, body, proxy, TLS, timeout, retry, and rate-limit options.

Definition at line 16 of file HttpRequest.hpp.

Member Function Documentation

◆ add_valid_status()

void kurlyk::HttpRequest::add_valid_status ( long status)
inline

Adds a single valid HTTP status code.

Parameters
statusHTTP status code to add to the set of valid statuses.

Definition at line 221 of file HttpRequest.hpp.

◆ clear_valid_statuses()

void kurlyk::HttpRequest::clear_valid_statuses ( )
inline

Clears all valid status codes.

Definition at line 232 of file HttpRequest.hpp.

◆ set_accept_encoding()

void kurlyk::HttpRequest::set_accept_encoding ( bool identity = false,
bool deflate = false,
bool gzip = false,
bool brotli = false )
inline

Sets the Accept-Encoding header with optional encoding types.

Parameters
identityEnable "identity" encoding.
deflateEnable "deflate" encoding.
gzipEnable "gzip" encoding.
brotliEnable "br" (brotli) encoding.

Definition at line 108 of file HttpRequest.hpp.

◆ set_accept_language()

void kurlyk::HttpRequest::set_accept_language ( const std::string & value)
inline

Sets the Accept-Language header value.

Parameters
valueLanguage value to be sent with the Accept-Language header.

Definition at line 124 of file HttpRequest.hpp.

◆ set_ca_file()

void kurlyk::HttpRequest::set_ca_file ( const std::string & ca_file)
inline

Sets the path to the CA certificate file.

Parameters
ca_filePath to the CA certificate file.

Definition at line 256 of file HttpRequest.hpp.

◆ set_cert_file()

void kurlyk::HttpRequest::set_cert_file ( const std::string & cert_file)
inline

Sets the client certificate file path.

Parameters
cert_filePath to the client certificate file.

Definition at line 250 of file HttpRequest.hpp.

◆ set_connect_timeout()

void kurlyk::HttpRequest::set_connect_timeout ( long connect_timeout)
inline

Sets the connection timeout.

Parameters
connect_timeoutConnection timeout in seconds.

Definition at line 268 of file HttpRequest.hpp.

◆ set_content_type()

void kurlyk::HttpRequest::set_content_type ( const std::string & value)
inline

Sets the Content-Type header value.

Parameters
valueMIME type for the Content-Type header.

Definition at line 130 of file HttpRequest.hpp.

◆ set_cookie()

void kurlyk::HttpRequest::set_cookie ( const std::string & cookie)
inline

Sets the cookie data.

Parameters
cookieCookie data as a string.

Definition at line 244 of file HttpRequest.hpp.

◆ set_debug_header()

void kurlyk::HttpRequest::set_debug_header ( bool debug_header)
inline

Enables or disables debugging headers in output.

Parameters
debug_headerEnable (true) or disable (false) debug headers.

Definition at line 286 of file HttpRequest.hpp.

◆ set_origin()

void kurlyk::HttpRequest::set_origin ( const std::string & value)
inline

Sets the Origin header value.

Parameters
valueOrigin to be sent with the Origin header.

Definition at line 136 of file HttpRequest.hpp.

◆ set_proxy() [1/3]

void kurlyk::HttpRequest::set_proxy ( const std::string & ip,
int port )
inline

Sets the proxy server address.

Parameters
ipProxy server IP address.
portProxy server port.

Definition at line 149 of file HttpRequest.hpp.

◆ set_proxy() [2/3]

void kurlyk::HttpRequest::set_proxy ( const std::string & ip,
int port,
const std::string & username,
const std::string & password,
ProxyType type = ProxyType::PROXY_HTTP )
inline

Sets the proxy server address with authentication details.

Parameters
ipProxy server IP address.
portProxy server port.
usernameProxy username.
passwordProxy password.
typeProxy type.

Definition at line 173 of file HttpRequest.hpp.

◆ set_proxy() [3/3]

void kurlyk::HttpRequest::set_proxy ( const std::string & ip,
int port,
ProxyType type )
inline

Sets the proxy server address.

Parameters
ipProxy server IP address.
portProxy server port.
typeProxy type.

Definition at line 159 of file HttpRequest.hpp.

◆ set_proxy_auth() [1/2]

void kurlyk::HttpRequest::set_proxy_auth ( const std::string & auth)
inline

Sets the proxy authentication credentials.

Parameters
authProxy authentication in <username:password> format.

Definition at line 192 of file HttpRequest.hpp.

◆ set_proxy_auth() [2/2]

void kurlyk::HttpRequest::set_proxy_auth ( const std::string & username,
const std::string & password )
inline

Sets proxy authentication credentials.

Parameters
usernameProxy username.
passwordProxy password.

Definition at line 205 of file HttpRequest.hpp.

◆ set_proxy_server()

void kurlyk::HttpRequest::set_proxy_server ( const std::string & server)
inline

Sets the proxy server address.

Parameters
serverProxy address in <ip:port> format.

Definition at line 186 of file HttpRequest.hpp.

◆ set_proxy_type()

void kurlyk::HttpRequest::set_proxy_type ( ProxyType type)
inline

Sets the proxy type.

Parameters
typeType of proxy.

Definition at line 198 of file HttpRequest.hpp.

◆ set_referer()

void kurlyk::HttpRequest::set_referer ( const std::string & value)
inline

Sets the Referer header value.

Parameters
valueReferer URL to be sent with the Referer header.

Definition at line 142 of file HttpRequest.hpp.

◆ set_retry_attempts()

void kurlyk::HttpRequest::set_retry_attempts ( long retry_attempts,
long retry_delay_ms )
inline

Sets the number of retry attempts and delay before retrying.

Parameters
retry_attemptsMaximum number of retry attempts.
retry_delay_msDelay before retrying in milliseconds.

Definition at line 214 of file HttpRequest.hpp.

◆ set_streaming()

void kurlyk::HttpRequest::set_streaming ( bool streaming)
inline

Enables or disables intermediate callbacks for response body chunks.

Parameters
streamingEnable (true) or disable (false) streaming callbacks.

Definition at line 274 of file HttpRequest.hpp.

◆ set_timeout()

void kurlyk::HttpRequest::set_timeout ( long timeout)
inline

Sets the request timeout.

Parameters
timeoutTimeout in seconds.

Definition at line 262 of file HttpRequest.hpp.

◆ set_url() [1/3]

void kurlyk::HttpRequest::set_url ( const std::string & host,
const std::string & path,
const QueryParams & query )
inline

Sets the request URL with base URL, path, and query parameters.

Parameters
hostBase URL or host prefix, for example "https://example.com".
pathPath to resource.
queryQuery parameters in dictionary format.

Definition at line 84 of file HttpRequest.hpp.

◆ set_url() [2/3]

void kurlyk::HttpRequest::set_url ( const std::string & host,
const std::string & path,
const std::string & query = std::string() )
inline

Sets the request URL with base URL, path, and optional query parameters.

Parameters
hostBase URL or host prefix, for example "https://example.com".
pathPath to resource.
queryOptional query parameters as a string.

Definition at line 65 of file HttpRequest.hpp.

◆ set_url() [3/3]

void kurlyk::HttpRequest::set_url ( const std::string & url,
const QueryParams & query )
inline

Sets the request URL and appends optional query parameters.

Parameters
urlFull request URL.
queryQuery parameters in dictionary format.

Definition at line 95 of file HttpRequest.hpp.

◆ set_user_agent()

void kurlyk::HttpRequest::set_user_agent ( const std::string & user_agent)
inline

Sets the User-Agent header.

Parameters
user_agentUser-Agent string.

Definition at line 238 of file HttpRequest.hpp.

◆ set_valid_statuses()

void kurlyk::HttpRequest::set_valid_statuses ( const std::set< long > & statuses)
inline

Sets the valid HTTP status codes, replacing any existing values.

Parameters
statusesNew set of valid HTTP status codes.

Definition at line 227 of file HttpRequest.hpp.

◆ set_verbose()

void kurlyk::HttpRequest::set_verbose ( bool verbose)
inline

Enables or disables verbose mode.

Parameters
verboseEnable (true) or disable (false) verbose output.

Definition at line 280 of file HttpRequest.hpp.

Member Data Documentation

◆ accept_encoding

std::string kurlyk::HttpRequest::accept_encoding

Accept-Encoding header.

Definition at line 25 of file HttpRequest.hpp.

◆ auto_referer

bool kurlyk::HttpRequest::auto_referer = false

Automatically set Referer header.

Definition at line 41 of file HttpRequest.hpp.

◆ ca_file

std::string kurlyk::HttpRequest::ca_file

Path to the CA certificate file.

Definition at line 30 of file HttpRequest.hpp.

◆ ca_path

std::string kurlyk::HttpRequest::ca_path

Path to a directory containing CA certificates.

Definition at line 31 of file HttpRequest.hpp.

◆ cert_file

std::string kurlyk::HttpRequest::cert_file

Path to the client certificate file.

Definition at line 28 of file HttpRequest.hpp.

◆ clear_cookie_file

bool kurlyk::HttpRequest::clear_cookie_file = false

Flag to clear the cookie file at the start of the request.

Definition at line 55 of file HttpRequest.hpp.

◆ connect_timeout

long kurlyk::HttpRequest::connect_timeout = 10

Connection timeout in seconds.

Definition at line 46 of file HttpRequest.hpp.

◆ content

std::string kurlyk::HttpRequest::content

Data payload for the request.

Definition at line 23 of file HttpRequest.hpp.

◆ cookie

std::string kurlyk::HttpRequest::cookie

Cookie data as a string.

Definition at line 27 of file HttpRequest.hpp.

◆ cookie_file

std::string kurlyk::HttpRequest::cookie_file

Path to the cookie file; if empty, cookies are not saved.

Definition at line 26 of file HttpRequest.hpp.

◆ debug_header

bool kurlyk::HttpRequest::debug_header = false

Include headers in debug output (CURLOPT_HEADER).

Definition at line 59 of file HttpRequest.hpp.

◆ follow_location

bool kurlyk::HttpRequest::follow_location = true

Automatically follow HTTP redirects.

Definition at line 39 of file HttpRequest.hpp.

◆ general_rate_limit

HttpRateLimitHandlePtr kurlyk::HttpRequest::general_rate_limit

General rate limit handle.

Definition at line 47 of file HttpRequest.hpp.

◆ general_rate_limit_key

std::string kurlyk::HttpRequest::general_rate_limit_key

Key used to separate general rate limit state; empty means default shared state.

Definition at line 49 of file HttpRequest.hpp.

◆ group_id

uint64_t kurlyk::HttpRequest::group_id = 0

ID shared by related requests, for example all requests created by one HttpClient.

Definition at line 19 of file HttpRequest.hpp.

◆ head_only

bool kurlyk::HttpRequest::head_only = false

If true, does not download the response body (HEAD-like behavior).

Definition at line 42 of file HttpRequest.hpp.

◆ headers

Headers kurlyk::HttpRequest::headers

HTTP request headers.

Definition at line 20 of file HttpRequest.hpp.

◆ interface_name

std::string kurlyk::HttpRequest::interface_name

Network interface name to use for the request.

Definition at line 36 of file HttpRequest.hpp.

◆ key_file

std::string kurlyk::HttpRequest::key_file

Path to the private key for the client certificate.

Definition at line 29 of file HttpRequest.hpp.

◆ max_redirects

long kurlyk::HttpRequest::max_redirects = 10

Maximum allowed redirects.

Definition at line 40 of file HttpRequest.hpp.

◆ method

std::string kurlyk::HttpRequest::method = "GET"

HTTP request method (e.g., "GET", "POST").

Definition at line 22 of file HttpRequest.hpp.

◆ proxy_auth

std::string kurlyk::HttpRequest::proxy_auth

Proxy authentication in <username:password> format.

Definition at line 33 of file HttpRequest.hpp.

◆ proxy_server

std::string kurlyk::HttpRequest::proxy_server

Proxy address in <ip:port> format.

Definition at line 32 of file HttpRequest.hpp.

◆ proxy_tunnel

bool kurlyk::HttpRequest::proxy_tunnel = true

Enable proxy tunneling.

Definition at line 35 of file HttpRequest.hpp.

◆ proxy_type

ProxyType kurlyk::HttpRequest::proxy_type = ProxyType::PROXY_HTTP

Proxy type (e.g., HTTP, SOCKS5).

Definition at line 34 of file HttpRequest.hpp.

◆ request_id

uint64_t kurlyk::HttpRequest::request_id = 0

Unique ID of this concrete HTTP request.

Definition at line 18 of file HttpRequest.hpp.

◆ retry_attempts

long kurlyk::HttpRequest::retry_attempts = 0

Number of retry attempts in case of failure.

Definition at line 52 of file HttpRequest.hpp.

◆ retry_delay_ms

long kurlyk::HttpRequest::retry_delay_ms = 0

Delay between retry attempts in milliseconds.

Definition at line 53 of file HttpRequest.hpp.

◆ specific_rate_limit

HttpRateLimitHandlePtr kurlyk::HttpRequest::specific_rate_limit

Specific rate limit handle.

Definition at line 48 of file HttpRequest.hpp.

◆ specific_rate_limit_key

std::string kurlyk::HttpRequest::specific_rate_limit_key

Key used to separate specific rate limit state; empty means default shared state.

Definition at line 50 of file HttpRequest.hpp.

◆ streaming

bool kurlyk::HttpRequest::streaming = false

Enable intermediate callbacks for response body chunks.

Definition at line 43 of file HttpRequest.hpp.

◆ timeout

long kurlyk::HttpRequest::timeout = 30

Request timeout in seconds.

Definition at line 45 of file HttpRequest.hpp.

◆ url

std::string kurlyk::HttpRequest::url

Full request URL.

Definition at line 21 of file HttpRequest.hpp.

◆ use_interface

bool kurlyk::HttpRequest::use_interface = false

Enable the specified network interface.

Definition at line 37 of file HttpRequest.hpp.

◆ user_agent

std::string kurlyk::HttpRequest::user_agent

User-Agent header.

Definition at line 24 of file HttpRequest.hpp.

◆ valid_statuses

std::set<long> kurlyk::HttpRequest::valid_statuses = {200}

Set of valid HTTP response status codes.

Definition at line 51 of file HttpRequest.hpp.

◆ verbose

bool kurlyk::HttpRequest::verbose = false

Enable verbose output (CURLOPT_VERBOSE).

Definition at line 58 of file HttpRequest.hpp.


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