![]() |
Kurlyk
|
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). | |
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.
|
inline |
Adds a single valid HTTP status code.
| status | HTTP status code to add to the set of valid statuses. |
Definition at line 221 of file HttpRequest.hpp.
|
inline |
Clears all valid status codes.
Definition at line 232 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 108 of file HttpRequest.hpp.
|
inline |
Sets the Accept-Language header value.
| value | Language value to be sent with the Accept-Language header. |
Definition at line 124 of file HttpRequest.hpp.
|
inline |
Sets the path to the CA certificate file.
| ca_file | Path to the CA certificate file. |
Definition at line 256 of file HttpRequest.hpp.
|
inline |
Sets the client certificate file path.
| cert_file | Path to the client certificate file. |
Definition at line 250 of file HttpRequest.hpp.
|
inline |
Sets the connection timeout.
| connect_timeout | Connection timeout in seconds. |
Definition at line 268 of file HttpRequest.hpp.
|
inline |
Sets the Content-Type header value.
| value | MIME type for the Content-Type header. |
Definition at line 130 of file HttpRequest.hpp.
|
inline |
Sets the cookie data.
| cookie | Cookie data as a string. |
Definition at line 244 of file HttpRequest.hpp.
|
inline |
Enables or disables debugging headers in output.
| debug_header | Enable (true) or disable (false) debug headers. |
Definition at line 286 of file HttpRequest.hpp.
|
inline |
Sets the Origin header value.
| value | Origin to be sent with the Origin header. |
Definition at line 136 of file HttpRequest.hpp.
|
inline |
Sets the proxy server address.
| ip | Proxy server IP address. |
| port | Proxy server port. |
Definition at line 149 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 173 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 159 of file HttpRequest.hpp.
|
inline |
Sets the proxy authentication credentials.
| auth | Proxy authentication in <username:password> format. |
Definition at line 192 of file HttpRequest.hpp.
|
inline |
Sets proxy authentication credentials.
| username | Proxy username. |
| password | Proxy password. |
Definition at line 205 of file HttpRequest.hpp.
|
inline |
Sets the proxy server address.
| server | Proxy address in <ip:port> format. |
Definition at line 186 of file HttpRequest.hpp.
|
inline |
|
inline |
Sets the Referer header value.
| value | Referer URL to be sent with the Referer header. |
Definition at line 142 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 214 of file HttpRequest.hpp.
|
inline |
Enables or disables intermediate callbacks for response body chunks.
| streaming | Enable (true) or disable (false) streaming callbacks. |
Definition at line 274 of file HttpRequest.hpp.
|
inline |
Sets the request timeout.
| timeout | Timeout in seconds. |
Definition at line 262 of file HttpRequest.hpp.
|
inline |
Sets the request URL with base URL, path, and query parameters.
| host | Base URL or host prefix, for example "https://example.com". |
| path | Path to resource. |
| query | Query parameters in dictionary format. |
Definition at line 84 of file HttpRequest.hpp.
|
inline |
Sets the request URL with base URL, path, and optional query parameters.
| host | Base URL or host prefix, for example "https://example.com". |
| path | Path to resource. |
| query | Optional query parameters as a string. |
Definition at line 65 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 95 of file HttpRequest.hpp.
|
inline |
Sets the User-Agent header.
| user_agent | User-Agent string. |
Definition at line 238 of file HttpRequest.hpp.
|
inline |
Sets the valid HTTP status codes, replacing any existing values.
| statuses | New set of valid HTTP status codes. |
Definition at line 227 of file HttpRequest.hpp.
|
inline |
Enables or disables verbose mode.
| verbose | Enable (true) or disable (false) verbose output. |
Definition at line 280 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::accept_encoding |
Accept-Encoding header.
Definition at line 25 of file HttpRequest.hpp.
| bool kurlyk::HttpRequest::auto_referer = false |
Automatically set Referer header.
Definition at line 41 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::ca_file |
Path to the CA certificate file.
Definition at line 30 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::ca_path |
Path to a directory containing CA certificates.
Definition at line 31 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::cert_file |
Path to the client certificate file.
Definition at line 28 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 55 of file HttpRequest.hpp.
| long kurlyk::HttpRequest::connect_timeout = 10 |
Connection timeout in seconds.
Definition at line 46 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::content |
Data payload for the request.
Definition at line 23 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::cookie |
Cookie data as a string.
Definition at line 27 of file HttpRequest.hpp.
| 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.
| bool kurlyk::HttpRequest::debug_header = false |
Include headers in debug output (CURLOPT_HEADER).
Definition at line 59 of file HttpRequest.hpp.
| bool kurlyk::HttpRequest::follow_location = true |
Automatically follow HTTP redirects.
Definition at line 39 of file HttpRequest.hpp.
| HttpRateLimitHandlePtr kurlyk::HttpRequest::general_rate_limit |
General rate limit handle.
Definition at line 47 of file HttpRequest.hpp.
| 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.
| 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.
| 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 kurlyk::HttpRequest::headers |
HTTP request headers.
Definition at line 20 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::interface_name |
Network interface name to use for the request.
Definition at line 36 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::key_file |
Path to the private key for the client certificate.
Definition at line 29 of file HttpRequest.hpp.
| long kurlyk::HttpRequest::max_redirects = 10 |
Maximum allowed redirects.
Definition at line 40 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::method = "GET" |
HTTP request method (e.g., "GET", "POST").
Definition at line 22 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::proxy_auth |
Proxy authentication in <username:password> format.
Definition at line 33 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::proxy_server |
Proxy address in <ip:port> format.
Definition at line 32 of file HttpRequest.hpp.
| bool kurlyk::HttpRequest::proxy_tunnel = true |
Enable proxy tunneling.
Definition at line 35 of file HttpRequest.hpp.
| ProxyType kurlyk::HttpRequest::proxy_type = ProxyType::PROXY_HTTP |
Proxy type (e.g., HTTP, SOCKS5).
Definition at line 34 of file HttpRequest.hpp.
| uint64_t kurlyk::HttpRequest::request_id = 0 |
Unique ID of this concrete HTTP request.
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 52 of file HttpRequest.hpp.
| long kurlyk::HttpRequest::retry_delay_ms = 0 |
Delay between retry attempts in milliseconds.
Definition at line 53 of file HttpRequest.hpp.
| HttpRateLimitHandlePtr kurlyk::HttpRequest::specific_rate_limit |
Specific rate limit handle.
Definition at line 48 of file HttpRequest.hpp.
| 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.
| bool kurlyk::HttpRequest::streaming = false |
Enable intermediate callbacks for response body chunks.
Definition at line 43 of file HttpRequest.hpp.
| long kurlyk::HttpRequest::timeout = 30 |
Request timeout in seconds.
Definition at line 45 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::url |
Full request URL.
Definition at line 21 of file HttpRequest.hpp.
| bool kurlyk::HttpRequest::use_interface = false |
Enable the specified network interface.
Definition at line 37 of file HttpRequest.hpp.
| std::string kurlyk::HttpRequest::user_agent |
User-Agent header.
Definition at line 24 of file HttpRequest.hpp.
| std::set<long> kurlyk::HttpRequest::valid_statuses = {200} |
Set of valid HTTP response status codes.
Definition at line 51 of file HttpRequest.hpp.
| bool kurlyk::HttpRequest::verbose = false |
Enable verbose output (CURLOPT_VERBOSE).
Definition at line 58 of file HttpRequest.hpp.