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

A client class for making HTTP requests to a specific host. More...

#include <HttpClient.hpp>

Public Member Functions

 HttpClient ()
 Default constructor for HttpClient.
 
 HttpClient (const std::string &host)
 Constructs an HttpClient with the specified host.
 
 HttpClient (const HttpClient &)=delete
 
void operator= (const HttpClient &)=delete
 
virtual ~HttpClient ()
 Destructor for HttpClient.
 
void cancel_requests ()
 Cancels the active request associated with this client and waits for its completion.
 
void set_host (const std::string &host)
 Sets the host URL for the HTTP client.
 
void set_headers (const kurlyk::Headers &headers)
 Sets the default headers for HTTP requests.
 
void assign_rate_limit_id (long limit_id, RateLimitType type=RateLimitType::RL_GENERAL)
 Assigns an existing rate limit to the HTTP request.
 
void set_rate_limit_id (long limit_id, RateLimitType type=RateLimitType::RL_GENERAL)
 Sets the rate limit ID for the HTTP request (alias for assign_rate_limit_id).
 
void set_rate_limit (long requests_per_period, long period_ms, RateLimitType type=RateLimitType::RL_GENERAL)
 Sets the rate limit for HTTP requests.
 
void set_rate_limit_rpm (long requests_per_minute, RateLimitType type=RateLimitType::RL_GENERAL)
 Sets the rate limit based on requests per minute (RPM).
 
void set_rate_limit_rps (long requests_per_second, RateLimitType type=RateLimitType::RL_GENERAL)
 Sets the rate limit based on requests per second (RPS).
 
void set_accept_encoding (bool identity=false, bool deflate=false, bool gzip=false, bool brotli=false)
 Sets the Accept-Encoding header.
 
void set_accept_encoding (const std::string &value)
 Sets a custom Accept-Encoding header value.
 
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_dnt (const bool value)
 Sets the Do Not Track (DNT) header value.
 
void set_follow_location (bool value)
 Configures whether to follow redirects automatically.
 
void set_auto_referer (bool value)
 Configures whether to automatically set the Referer header on redirects.
 
void set_proxy_tunnel (bool value)
 Configures whether to use a tunneling proxy for HTTP requests.
 
void set_head_only (bool value)
 Configures whether to send only the HTTP headers (HEAD request).
 
void set_proxy (const std::string &ip, int port, ProxyType type=ProxyType::PROXY_HTTP)
 Sets the proxy server address.
 
void set_proxy (const std::string &ip, const 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_auth (const std::string &username, const std::string &password)
 Sets proxy authentication credentials.
 
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_retry_attempts (long retry_attempts, long retry_delay_ms)
 Sets retry attempts and delay between retries for HTTP requests.
 
void add_valid_status (long status)
 Adds a valid HTTP status code to the request.
 
void set_valid_statuses (const std::set< long > &statuses)
 Replaces all valid HTTP status codes for the request.
 
void clear_valid_statuses ()
 Clears the set of valid HTTP status codes for the request.
 
void set_user_agent (const std::string &user_agent)
 Sets the User-Agent header.
 
void set_cookie (const std::string &cookie)
 Sets the cookie string for HTTP requests.
 
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 timeout duration for HTTP requests.
 
void set_connect_timeout (long connect_timeout)
 Sets the connection timeout duration.
 
void set_verbose (bool verbose)
 Enables or disables verbose output.
 
void set_debug_header (bool debug_header)
 Enables or disables debug headers.
 
void set_max_redirects (long max_redirects)
 Sets the maximum number of redirects for the client.
 
bool request (const std::string &method, const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content, HttpResponseCallback callback)
 Sends an HTTP request with the specified method, path, and parameters.
 
bool request (const std::string &method, const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content, long specific_rate_limit_id, HttpResponseCallback callback)
 Sends an HTTP request with the specified method, path, parameters, and specific rate limit ID.
 
bool get (const std::string &path, const QueryParams &query, const Headers &headers, HttpResponseCallback callback)
 Sends a GET request.
 
bool post (const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content, HttpResponseCallback callback)
 Sends a POST request.
 
bool get (const std::string &path, const QueryParams &query, const Headers &headers, long specific_rate_limit_id, HttpResponseCallback callback)
 Sends a GET request with a specific rate limit ID.
 
bool post (const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content, long specific_rate_limit_id, HttpResponseCallback callback)
 Sends a POST request with a specific rate limit ID.
 
std::future< HttpResponsePtrrequest (const std::string &method, const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content)
 Sends an HTTP request with a specified method, path, and parameters, and returns a future with the response.
 
std::future< HttpResponsePtrrequest (const std::string &method, const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content, long specific_rate_limit_id)
 Sends an HTTP request with a specified method, path, specific rate limit ID and parameters, and returns a future with the response.
 
std::future< HttpResponsePtrget (const std::string &path, const QueryParams &query, const Headers &headers)
 Sends a GET request asynchronously and returns a future with the response.
 
std::future< HttpResponsePtrpost (const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content)
 Sends a POST request asynchronously and returns a future with the response.
 
std::future< HttpResponsePtrget (const std::string &path, const QueryParams &query, const Headers &headers, long specific_rate_limit_id)
 Sends an asynchronous GET request with a specific rate limit ID and returns a future with the response.
 
std::future< HttpResponsePtrpost (const std::string &path, const QueryParams &query, const Headers &headers, const std::string &content, long specific_rate_limit_id)
 Sends an asynchronous POST request with a specific rate limit ID and returns a future with the response.
 

Private Member Functions

bool request (std::unique_ptr< HttpRequest > request_ptr, HttpResponseCallback callback)
 Adds the request to the request manager and notifies the worker to process it.
 
void safe_submit_request (std::shared_ptr< std::promise< HttpResponsePtr > > promise, std::unique_ptr< HttpRequest > request_ptr, HttpResponseCallback callback)
 Submits a request and propagates any failure to the provided promise.
 

Static Private Member Functions

static void safe_set_response (std::shared_ptr< std::promise< HttpResponsePtr > > promise, HttpResponsePtr response)
 Safely sets the response value on the given promise.
 
static void ensure_initialized ()
 Ensures that the network worker and request manager are initialized.
 

Private Attributes

HttpRequest m_request
 The request object used for configuring and sending requests.
 
std::string m_host
 The base host URL for the HTTP client.
 
bool is_general_limit_owned = false
 Flag indicating if the client owns the general rate limit.
 
bool is_specific_limit_owned = false
 Flag indicating if the client owns the specific rate limit.
 

Detailed Description

A client class for making HTTP requests to a specific host.

This class provides methods to configure the client, including rate limiting, proxy settings, retry logic, and more.

Definition at line 13 of file HttpClient.hpp.

Constructor & Destructor Documentation

◆ HttpClient() [1/3]

kurlyk::HttpClient::HttpClient ( )
inline

Default constructor for HttpClient.

Definition at line 17 of file HttpClient.hpp.

◆ HttpClient() [2/3]

kurlyk::HttpClient::HttpClient ( const std::string & host)
inline

Constructs an HttpClient with the specified host.

Parameters
hostThe base host URL for the HTTP client.

Definition at line 24 of file HttpClient.hpp.

◆ HttpClient() [3/3]

kurlyk::HttpClient::HttpClient ( const HttpClient & )
delete

◆ ~HttpClient()

virtual kurlyk::HttpClient::~HttpClient ( )
inlinevirtual

Destructor for HttpClient.

Definition at line 34 of file HttpClient.hpp.

Member Function Documentation

◆ add_valid_status()

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

Adds a valid HTTP status code to the request.

Parameters
statusThe HTTP status code to allow.

Definition at line 303 of file HttpClient.hpp.

◆ assign_rate_limit_id()

void kurlyk::HttpClient::assign_rate_limit_id ( long limit_id,
RateLimitType type = RateLimitType::RL_GENERAL )
inline

Assigns an existing rate limit to the HTTP request.

Parameters
limit_idThe unique identifier of the rate limit to assign.
typeSpecifies the rate limit type (general or specific).

Definition at line 88 of file HttpClient.hpp.

◆ cancel_requests()

void kurlyk::HttpClient::cancel_requests ( )
inline

Cancels the active request associated with this client and waits for its completion.

Note
If no active request is associated or the ID is invalid, the method may have no effect.

Definition at line 47 of file HttpClient.hpp.

◆ clear_valid_statuses()

void kurlyk::HttpClient::clear_valid_statuses ( )
inline

Clears the set of valid HTTP status codes for the request.

Definition at line 314 of file HttpClient.hpp.

◆ ensure_initialized()

static void kurlyk::HttpClient::ensure_initialized ( )
inlinestaticprivate

Ensures that the network worker and request manager are initialized.

Definition at line 710 of file HttpClient.hpp.

◆ get() [1/4]

std::future< HttpResponsePtr > kurlyk::HttpClient::get ( const std::string & path,
const QueryParams & query,
const Headers & headers )
inline

Sends a GET request asynchronously and returns a future with the response.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
Returns
A future containing the HttpResponsePtr object.

Definition at line 586 of file HttpClient.hpp.

◆ get() [2/4]

bool kurlyk::HttpClient::get ( const std::string & path,
const QueryParams & query,
const Headers & headers,
HttpResponseCallback callback )
inline

Sends a GET request.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
callbackThe callback function to be called when the request is completed.
Returns
true if the request was successfully added to the RequestManager; false otherwise.

Definition at line 442 of file HttpClient.hpp.

◆ get() [3/4]

std::future< HttpResponsePtr > kurlyk::HttpClient::get ( const std::string & path,
const QueryParams & query,
const Headers & headers,
long specific_rate_limit_id )
inline

Sends an asynchronous GET request with a specific rate limit ID and returns a future with the response.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
specific_rate_limit_idThe specific rate limit ID to be applied to this request.
Returns
A future containing the HttpResponsePtr object.

Definition at line 613 of file HttpClient.hpp.

◆ get() [4/4]

bool kurlyk::HttpClient::get ( const std::string & path,
const QueryParams & query,
const Headers & headers,
long specific_rate_limit_id,
HttpResponseCallback callback )
inline

Sends a GET request with a specific rate limit ID.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
specific_rate_limit_idThe specific rate limit ID to be applied to this request.
callbackThe callback function to be called when the request is completed.
Returns
true if the request was successfully added to the RequestManager; false otherwise.

Definition at line 473 of file HttpClient.hpp.

◆ operator=()

void kurlyk::HttpClient::operator= ( const HttpClient & )
delete

◆ post() [1/4]

std::future< HttpResponsePtr > kurlyk::HttpClient::post ( const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content )
inline

Sends a POST request asynchronously and returns a future with the response.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
Returns
A future containing the HttpResponsePtr object.

Definition at line 599 of file HttpClient.hpp.

◆ post() [2/4]

bool kurlyk::HttpClient::post ( const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content,
HttpResponseCallback callback )
inline

Sends a POST request.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
callbackThe callback function to be called when the request is completed.
Returns
true if the request was successfully added to the RequestManager; false otherwise.

Definition at line 457 of file HttpClient.hpp.

◆ post() [3/4]

std::future< HttpResponsePtr > kurlyk::HttpClient::post ( const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content,
long specific_rate_limit_id )
inline

Sends an asynchronous POST request with a specific rate limit ID and returns a future with the response.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
specific_rate_limit_idThe specific rate limit ID to be applied to this request.
Returns
A future containing the HttpResponsePtr object.

Definition at line 628 of file HttpClient.hpp.

◆ post() [4/4]

bool kurlyk::HttpClient::post ( const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content,
long specific_rate_limit_id,
HttpResponseCallback callback )
inline

Sends a POST request with a specific rate limit ID.

Parameters
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
specific_rate_limit_idThe specific rate limit ID to be applied to this request.
callbackThe callback function to be called when the request is completed.
Returns
true if the request was successfully added to the RequestManager; false otherwise.

Definition at line 490 of file HttpClient.hpp.

◆ request() [1/5]

std::future< HttpResponsePtr > kurlyk::HttpClient::request ( const std::string & method,
const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content )
inline

Sends an HTTP request with a specified method, path, and parameters, and returns a future with the response.

Parameters
methodThe HTTP method (e.g., "GET", "POST").
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
Returns
A future containing the HttpResponsePtr object.

Definition at line 507 of file HttpClient.hpp.

◆ request() [2/5]

bool kurlyk::HttpClient::request ( const std::string & method,
const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content,
HttpResponseCallback callback )
inline

Sends an HTTP request with the specified method, path, and parameters.

Parameters
methodThe HTTP method (e.g., "GET", "POST").
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
callbackThe callback function to be called when the request is completed.
Returns
true if the request was successfully added to the RequestManager; false otherwise.

Definition at line 380 of file HttpClient.hpp.

◆ request() [3/5]

std::future< HttpResponsePtr > kurlyk::HttpClient::request ( const std::string & method,
const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content,
long specific_rate_limit_id )
inline

Sends an HTTP request with a specified method, path, specific rate limit ID and parameters, and returns a future with the response.

Parameters
methodThe HTTP method (e.g., "GET", "POST").
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
specific_rate_limit_idThe specific rate limit ID to be applied to this request.
Returns
A future containing the HttpResponsePtr object.

Definition at line 544 of file HttpClient.hpp.

◆ request() [4/5]

bool kurlyk::HttpClient::request ( const std::string & method,
const std::string & path,
const QueryParams & query,
const Headers & headers,
const std::string & content,
long specific_rate_limit_id,
HttpResponseCallback callback )
inline

Sends an HTTP request with the specified method, path, parameters, and specific rate limit ID.

Parameters
methodThe HTTP method (e.g., "GET", "POST").
pathThe URL path for the request.
queryThe query arguments.
headersThe HTTP headers.
contentThe request body content.
specific_rate_limit_idThe specific rate limit ID to be applied to this request.
callbackThe callback function to be called when the request is completed.
Returns
true if the request was successfully added to the RequestManager; false otherwise.

Definition at line 408 of file HttpClient.hpp.

◆ request() [5/5]

bool kurlyk::HttpClient::request ( std::unique_ptr< HttpRequest > request_ptr,
HttpResponseCallback callback )
inlineprivate

Adds the request to the request manager and notifies the worker to process it.

Parameters
request_ptrThe HTTP request to be sent.
callbackThe callback function to be called when the request is completed.
Returns
true if the request was successfully added to the RequestManager; false otherwise.

Definition at line 647 of file HttpClient.hpp.

◆ safe_set_response()

static void kurlyk::HttpClient::safe_set_response ( std::shared_ptr< std::promise< HttpResponsePtr > > promise,
HttpResponsePtr response )
inlinestaticprivate

Safely sets the response value on the given promise.

Parameters
promisePromise that receives the HTTP response.
responseCompleted HTTP response to forward to the caller.

Definition at line 658 of file HttpClient.hpp.

◆ safe_submit_request()

void kurlyk::HttpClient::safe_submit_request ( std::shared_ptr< std::promise< HttpResponsePtr > > promise,
std::unique_ptr< HttpRequest > request_ptr,
HttpResponseCallback callback )
inlineprivate

Submits a request and propagates any failure to the provided promise.

Parameters
promisePromise to signal upon success or failure.
request_ptrPrepared HTTP request to enqueue.
callbackCallback executed when the request completes.

Definition at line 681 of file HttpClient.hpp.

◆ set_accept_encoding() [1/2]

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

Sets the Accept-Encoding header.

Parameters
identityEnable identity encoding.
deflateEnable deflate encoding.
gzipEnable gzip encoding.
brotliEnable brotli encoding.

Definition at line 172 of file HttpClient.hpp.

◆ set_accept_encoding() [2/2]

void kurlyk::HttpClient::set_accept_encoding ( const std::string & value)
inline

Sets a custom Accept-Encoding header value.

Parameters
valueThe custom value for the Accept-Encoding header.

Definition at line 182 of file HttpClient.hpp.

◆ set_accept_language()

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

Sets the Accept-Language header value.

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

Definition at line 188 of file HttpClient.hpp.

◆ set_auto_referer()

void kurlyk::HttpClient::set_auto_referer ( bool value)
inline

Configures whether to automatically set the Referer header on redirects.

Parameters
valueIf true, enables automatically setting the Referer header during redirects.

Definition at line 224 of file HttpClient.hpp.

◆ set_ca_file()

void kurlyk::HttpClient::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 338 of file HttpClient.hpp.

◆ set_cert_file()

void kurlyk::HttpClient::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 332 of file HttpClient.hpp.

◆ set_connect_timeout()

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

Sets the connection timeout duration.

Parameters
connect_timeoutConnection timeout in seconds.

Definition at line 350 of file HttpClient.hpp.

◆ set_content_type()

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

Sets the Content-Type header value.

Parameters
valueThe MIME type for the Content-Type header.

Definition at line 194 of file HttpClient.hpp.

◆ set_cookie()

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

Sets the cookie string for HTTP requests.

Parameters
cookieCookie data as a single string.

Definition at line 326 of file HttpClient.hpp.

◆ set_debug_header()

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

Enables or disables debug headers.

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

Definition at line 362 of file HttpClient.hpp.

◆ set_dnt()

void kurlyk::HttpClient::set_dnt ( const bool value)
inline

Sets the Do Not Track (DNT) header value.

Parameters
valueIf true, sets the DNT header to "1".

Definition at line 212 of file HttpClient.hpp.

◆ set_follow_location()

void kurlyk::HttpClient::set_follow_location ( bool value)
inline

Configures whether to follow redirects automatically.

Parameters
valueIf true, enables following HTTP redirects.

Definition at line 218 of file HttpClient.hpp.

◆ set_head_only()

void kurlyk::HttpClient::set_head_only ( bool value)
inline

Configures whether to send only the HTTP headers (HEAD request).

Parameters
valueIf true, the request will not download the response body (uses CURLOPT_NOBODY internally). Useful for measuring latency or checking resource availability without downloading content.

Definition at line 237 of file HttpClient.hpp.

◆ set_headers()

void kurlyk::HttpClient::set_headers ( const kurlyk::Headers & headers)
inline

Sets the default headers for HTTP requests.

Parameters
headersThe headers to be included with each request.

Definition at line 81 of file HttpClient.hpp.

◆ set_host()

void kurlyk::HttpClient::set_host ( const std::string & host)
inline

Sets the host URL for the HTTP client.

Parameters
hostThe base host URL for HTTP requests.

Definition at line 75 of file HttpClient.hpp.

◆ set_max_redirects()

void kurlyk::HttpClient::set_max_redirects ( long max_redirects)
inline

Sets the maximum number of redirects for the client.

Parameters
max_redirectsThe maximum number of redirects allowed.

Definition at line 368 of file HttpClient.hpp.

◆ set_origin()

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

Sets the Origin header value.

Parameters
valueThe origin to be sent with the Origin header.

Definition at line 200 of file HttpClient.hpp.

◆ set_proxy() [1/2]

void kurlyk::HttpClient::set_proxy ( const std::string & ip,
const 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.
typeThe type of proxy, defaulting to HTTP.

Definition at line 258 of file HttpClient.hpp.

◆ set_proxy() [2/2]

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

Sets the proxy server address.

Parameters
ipProxy server IP address.
portProxy server port.
typeThe type of proxy, defaulting to HTTP.

Definition at line 245 of file HttpClient.hpp.

◆ set_proxy_auth() [1/2]

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

Sets the proxy authentication credentials.

Parameters
authProxy authentication in <username:password> format.

Definition at line 284 of file HttpClient.hpp.

◆ set_proxy_auth() [2/2]

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

Sets proxy authentication credentials.

Parameters
usernameProxy username.
passwordProxy password.

Definition at line 270 of file HttpClient.hpp.

◆ set_proxy_server()

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

Sets the proxy server address.

Parameters
serverProxy address in <ip:port> format.

Definition at line 278 of file HttpClient.hpp.

◆ set_proxy_tunnel()

void kurlyk::HttpClient::set_proxy_tunnel ( bool value)
inline

Configures whether to use a tunneling proxy for HTTP requests.

Parameters
valueIf true, enables tunneling through the proxy server. Tunneling proxies are typically used for HTTPS requests to securely forward traffic.

Definition at line 230 of file HttpClient.hpp.

◆ set_proxy_type()

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

Sets the proxy type.

Parameters
typeType of proxy.

Definition at line 290 of file HttpClient.hpp.

◆ set_rate_limit()

void kurlyk::HttpClient::set_rate_limit ( long requests_per_period,
long period_ms,
RateLimitType type = RateLimitType::RL_GENERAL )
inline

Sets the rate limit for HTTP requests.

Parameters
requests_per_periodThe maximum number of requests allowed within the specified period.
period_msThe duration of the period in milliseconds.
typeThe type of rate limit (either general or specific).

Definition at line 124 of file HttpClient.hpp.

◆ set_rate_limit_id()

void kurlyk::HttpClient::set_rate_limit_id ( long limit_id,
RateLimitType type = RateLimitType::RL_GENERAL )
inline

Sets the rate limit ID for the HTTP request (alias for assign_rate_limit_id).

Parameters
limit_idThe unique identifier of the rate limit to assign.
typeSpecifies the rate limit type (general or specific).
Note
This method is an alias for assign_rate_limit_id.

Definition at line 114 of file HttpClient.hpp.

◆ set_rate_limit_rpm()

void kurlyk::HttpClient::set_rate_limit_rpm ( long requests_per_minute,
RateLimitType type = RateLimitType::RL_GENERAL )
inline

Sets the rate limit based on requests per minute (RPM).

Parameters
requests_per_minuteMaximum number of requests allowed per minute.
typeThe type of rate limit (either general or specific).

Definition at line 150 of file HttpClient.hpp.

◆ set_rate_limit_rps()

void kurlyk::HttpClient::set_rate_limit_rps ( long requests_per_second,
RateLimitType type = RateLimitType::RL_GENERAL )
inline

Sets the rate limit based on requests per second (RPS).

Parameters
requests_per_secondMaximum number of requests allowed per second.
typeThe type of rate limit (either general or specific).

Definition at line 160 of file HttpClient.hpp.

◆ set_referer()

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

Sets the Referer header value.

Parameters
valueThe referer URL to be sent with the Referer header.

Definition at line 206 of file HttpClient.hpp.

◆ set_retry_attempts()

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

Sets retry attempts and delay between retries for HTTP requests.

Parameters
retry_attemptsNumber of retry attempts.
retry_delay_msDelay in milliseconds between retry attempts.

Definition at line 297 of file HttpClient.hpp.

◆ set_timeout()

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

Sets the timeout duration for HTTP requests.

Parameters
timeoutTimeout duration in seconds.

Definition at line 344 of file HttpClient.hpp.

◆ set_user_agent()

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

Sets the User-Agent header.

Parameters
user_agentUser-Agent string.

Definition at line 320 of file HttpClient.hpp.

◆ set_valid_statuses()

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

Replaces all valid HTTP status codes for the request.

Parameters
statusesThe set of HTTP status codes to allow.

Definition at line 309 of file HttpClient.hpp.

◆ set_verbose()

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

Enables or disables verbose output.

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

Definition at line 356 of file HttpClient.hpp.

Member Data Documentation

◆ is_general_limit_owned

bool kurlyk::HttpClient::is_general_limit_owned = false
private

Flag indicating if the client owns the general rate limit.

Definition at line 640 of file HttpClient.hpp.

◆ is_specific_limit_owned

bool kurlyk::HttpClient::is_specific_limit_owned = false
private

Flag indicating if the client owns the specific rate limit.

Definition at line 641 of file HttpClient.hpp.

◆ m_host

std::string kurlyk::HttpClient::m_host
private

The base host URL for the HTTP client.

Definition at line 639 of file HttpClient.hpp.

◆ m_request

HttpRequest kurlyk::HttpClient::m_request
private

The request object used for configuring and sending requests.

Definition at line 638 of file HttpClient.hpp.


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