![]() |
Kurlyk
|
Represents an HTTP request. 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 host, path, and optional query parameters. | |
void | set_url (const std::string &host, const std::string &path, const QueryParams &query) |
Sets the request URL with host, path, and optional query parameters as a dictionary. | |
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_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 identifier for the request (default is 0). | |
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, sends the request without a response body (HEAD-like behavior). | |
long | timeout = 30 |
Request timeout in seconds. | |
long | connect_timeout = 10 |
Connection timeout in seconds. | |
long | general_rate_limit_id = 0 |
ID for general rate limiting. | |
long | specific_rate_limit_id = 0 |
ID for specific rate limiting. | |
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). | |
Represents an HTTP request.
The HttpRequest class encapsulates various parameters and settings for an HTTP request, including headers, URL, method, data, and connection options. It provides methods for configuring these parameters and handling HTTP requests.
Definition at line 16 of file HttpRequest.hpp.
|
inline |
Adds a single valid HTTP status code.
status | The HTTP status code to add to the set of valid statuses. |
Definition at line 217 of file HttpRequest.hpp.
|
inline |
Clears all valid status codes.
Definition at line 228 of file HttpRequest.hpp.
|
inline |
Sets the Accept-Encoding header with optional encoding types.
identity | Enable "identity" encoding. |
deflate | Enable "deflate" encoding. |
gzip | Enable "gzip" encoding. |
brotli | Enable "br" (brotli) encoding. |
Definition at line 104 of file HttpRequest.hpp.
|
inline |
Sets the Accept-Language header value.
value | The language value to be sent with the Accept-Language header. |
Definition at line 120 of file HttpRequest.hpp.
|
inline |
Sets the path to the CA certificate file.
ca_file | Path to the CA certificate file. |
Definition at line 252 of file HttpRequest.hpp.
|
inline |
Sets the client certificate file path.
cert_file | Path to the client certificate file. |
Definition at line 246 of file HttpRequest.hpp.
|
inline |
Sets the connection timeout.
connect_timeout | Connection timeout in seconds. |
Definition at line 264 of file HttpRequest.hpp.
|
inline |
Sets the Content-Type header value.
value | The MIME type for the Content-Type header. |
Definition at line 126 of file HttpRequest.hpp.
|
inline |
Sets the cookie data.
cookie | Cookie data as a string. |
Definition at line 240 of file HttpRequest.hpp.
|
inline |
Enables or disables debugging headers in output.
debug_header | Enable (true) or disable (false) debug headers. |
Definition at line 276 of file HttpRequest.hpp.
|
inline |
Sets the Origin header value.
value | The origin to be sent with the Origin header. |
Definition at line 132 of file HttpRequest.hpp.
|
inline |
Sets the proxy server address.
ip | Proxy server IP address. |
port | Proxy server port. |
Definition at line 145 of file HttpRequest.hpp.
|
inline |
Sets the proxy server address with authentication details.
ip | Proxy server IP address. |
port | Proxy server port. |
username | Proxy username. |
password | Proxy password. |
type | Proxy type. |
Definition at line 169 of file HttpRequest.hpp.
|
inline |
Sets the proxy server address.
ip | Proxy server IP address. |
port | Proxy server port. |
type | Proxy type. |
Definition at line 155 of file HttpRequest.hpp.
|
inline |
Sets the proxy authentication credentials.
auth | Proxy authentication in <username:password> format. |
Definition at line 188 of file HttpRequest.hpp.
|
inline |
Sets proxy authentication credentials.
username | Proxy username. |
password | Proxy password. |
Definition at line 201 of file HttpRequest.hpp.
|
inline |
Sets the proxy server address.
server | Proxy address in <ip:port> format. |
Definition at line 182 of file HttpRequest.hpp.
|
inline |
|
inline |
Sets the Referer header value.
value | The referer URL to be sent with the Referer header. |
Definition at line 138 of file HttpRequest.hpp.
|
inline |
Sets the number of retry attempts and delay before retrying.
retry_attempts | Maximum number of retry attempts. |
retry_delay_ms | Delay before retrying in milliseconds. |
Definition at line 210 of file HttpRequest.hpp.
|
inline |
Sets the request timeout.
timeout | Timeout in seconds. |
Definition at line 258 of file HttpRequest.hpp.
|
inline |
Sets the request URL with host, path, and optional query parameters as a dictionary.
host | Hostname or IP address. |
path | Path to resource. |
query | Query parameters in dictionary format. |
Definition at line 80 of file HttpRequest.hpp.
|
inline |
Sets the request URL with host, path, and optional query parameters.
host | Hostname or IP address. |
path | Path to resource. |
query | Optional query parameters as a string. |
Definition at line 61 of file HttpRequest.hpp.
|
inline |
Sets the request URL and appends optional query parameters.
url | Full request URL. |
query | Query parameters in dictionary format. |
Definition at line 91 of file HttpRequest.hpp.
|
inline |
Sets the User-Agent header.
user_agent | User-Agent string. |
Definition at line 234 of file HttpRequest.hpp.
|
inline |
Sets the valid HTTP status codes, replacing any existing values.
statuses | The new set of valid HTTP status codes. |
Definition at line 223 of file HttpRequest.hpp.
|
inline |
Enables or disables verbose mode.
verbose | Enable (true) or disable (false) verbose output. |
Definition at line 270 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::accept_encoding |
Accept-Encoding header.
Definition at line 24 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::auto_referer = false |
Automatically set Referer header.
Definition at line 40 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::ca_file |
Path to the CA certificate file.
Definition at line 29 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::ca_path |
Path to a directory containing CA certificates.
Definition at line 30 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::cert_file |
Path to the client certificate file.
Definition at line 27 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::clear_cookie_file = false |
Flag to clear the cookie file at the start of the request.
Definition at line 51 of file HttpRequest.hpp.
long kurlyk::HttpRequest::connect_timeout = 10 |
Connection timeout in seconds.
Definition at line 44 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::content |
Data payload for the request.
Definition at line 22 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::cookie |
Cookie data as a string.
Definition at line 26 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::cookie_file |
Path to the cookie file; if empty, cookies are not saved.
Definition at line 25 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::debug_header = false |
Include headers in debug output (CURLOPT_HEADER).
Definition at line 55 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::follow_location = true |
Automatically follow HTTP redirects.
Definition at line 38 of file HttpRequest.hpp.
long kurlyk::HttpRequest::general_rate_limit_id = 0 |
ID for general rate limiting.
Definition at line 45 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::head_only = false |
If true, sends the request without a response body (HEAD-like behavior).
Definition at line 41 of file HttpRequest.hpp.
Headers kurlyk::HttpRequest::headers |
HTTP request headers.
Definition at line 19 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::interface_name |
Network interface name to use for the request.
Definition at line 35 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::key_file |
Path to the private key for the client certificate.
Definition at line 28 of file HttpRequest.hpp.
long kurlyk::HttpRequest::max_redirects = 10 |
Maximum allowed redirects.
Definition at line 39 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::method = "GET" |
HTTP request method (e.g., "GET", "POST").
Definition at line 21 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::proxy_auth |
Proxy authentication in <username:password> format.
Definition at line 32 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::proxy_server |
Proxy address in <ip:port> format.
Definition at line 31 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::proxy_tunnel = true |
Enable proxy tunneling.
Definition at line 34 of file HttpRequest.hpp.
ProxyType kurlyk::HttpRequest::proxy_type = ProxyType::PROXY_HTTP |
Proxy type (e.g., HTTP, SOCKS5).
Definition at line 33 of file HttpRequest.hpp.
uint64_t kurlyk::HttpRequest::request_id = 0 |
Unique identifier for the request (default is 0).
Definition at line 18 of file HttpRequest.hpp.
long kurlyk::HttpRequest::retry_attempts = 0 |
Number of retry attempts in case of failure.
Definition at line 48 of file HttpRequest.hpp.
long kurlyk::HttpRequest::retry_delay_ms = 0 |
Delay between retry attempts in milliseconds.
Definition at line 49 of file HttpRequest.hpp.
long kurlyk::HttpRequest::specific_rate_limit_id = 0 |
ID for specific rate limiting.
Definition at line 46 of file HttpRequest.hpp.
long kurlyk::HttpRequest::timeout = 30 |
Request timeout in seconds.
Definition at line 43 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::url |
Full request URL.
Definition at line 20 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::use_interface = false |
Enable the specified network interface.
Definition at line 36 of file HttpRequest.hpp.
std::string kurlyk::HttpRequest::user_agent |
User-Agent header.
Definition at line 23 of file HttpRequest.hpp.
std::set<long> kurlyk::HttpRequest::valid_statuses = {200} |
Set of valid HTTP response status codes.
Definition at line 47 of file HttpRequest.hpp.
bool kurlyk::HttpRequest::verbose = false |
Enable verbose output (CURLOPT_VERBOSE).
Definition at line 54 of file HttpRequest.hpp.