![]() |
Kurlyk
|
Classes | |
class | CaseInsensitiveEqual |
Functor for case-insensitive string comparison. More... | |
class | CaseInsensitiveHash |
Functor for generating case-insensitive hash values for strings. More... | |
class | ClientErrorCategory |
Custom std::error_category for reporting internal client errors not tied to specific protocols (e.g., CURL, HTTP). More... | |
class | CurlErrorCategory |
Represents a custom error category for CURL errors, enabling integration with std::error_code. More... | |
class | EventQueue |
A thread-safe event queue that supports blocking and non-blocking event retrieval. More... | |
class | HttpErrorCategory |
Custom error category that maps HTTP status codes (e.g., 404, 500) to human-readable error messages. More... | |
class | ThreadSafePrintStream |
Thread-safe stream class for printing to console from multiple threads. More... | |
class | WebSocketErrorCategory |
Error category class for WebSocketError enumeration. More... | |
Typedefs | |
using | CaseInsensitiveMultimap = std::unordered_multimap<std::string, std::string, CaseInsensitiveHash, CaseInsensitiveEqual> |
A case-insensitive unordered multimap for storing HTTP headers. | |
using | CaseInsensitiveCookieMultimap = std::unordered_multimap<std::string, Cookie, CaseInsensitiveHash, CaseInsensitiveEqual> |
A case-insensitive unordered multimap specifically for storing HTTP cookies. | |
Enumerations | |
enum class | ClientError { CancelledByUser = 1 , AbortedDuringDestruction , ClientNotInitialized , InvalidConfiguration , NotConnected } |
Defines errors related to the internal state or lifecycle of the HTTP/WebSocket client. More... | |
enum class | WebSocketError { ConnectionFailed = 1 , UnexpectedClose , ProtocolViolation , UnsupportedDataType , InvalidCloseCode , CompressionError } |
Represents protocol-level WebSocket errors. More... | |
Functions | |
bool | case_insensitive_equal (const std::string &str1, const std::string &str2) noexcept |
Compares two strings case-insensitively. | |
const std::error_category & | client_error_category () |
Returns the singleton instance of the ClientErrorCategory. | |
std::error_code | make_error_code (ClientError e) |
Creates a std::error_code from a ClientError value. | |
std::error_code | make_error_code (CURLcode e) |
Creates an std::error_code from a CURLcode, allowing CURL errors to be used with the std::error_code API. | |
bool | is_valid_email_id (const std::string &str) |
Validates an email address format. | |
void | parse_http_header_pair (const char *buffer, const size_t &size, std::string &key, std::string &value) |
Parses a header pair from a buffer. | |
std::string | to_query_string (const QueryParams &query, const std::string &prefix=std::string()) noexcept |
Converts a map of query parameters into a URL query string. | |
std::string | to_cookie_string (const CaseInsensitiveMultimap &cookies) |
Converts a CaseInsensitiveMultimap to a string format suitable for HTTP Cookie headers. | |
std::string | to_cookie_string (const Cookies &cookies) |
Converts a CaseInsensitiveMultimap to a string format suitable for HTTP Cookie headers. | |
Cookies | parse_cookie (std::string cookie) |
Parses a cookie string into a Cookies object. | |
std::string | remove_http_prefix (const std::string &url) |
Removes the first occurrence of "https://" or "http://" from the given URL. | |
std::error_code | make_http_error (int status_code) |
Creates an std::error_code from an HTTP status code. | |
bool | is_http_error (const std::error_code &ec) |
Checks whether the given error code belongs to the HTTP error category. | |
std::string | get_exec_dir () |
Retrieves the directory of the executable file. | |
std::string | percent_encode (const std::string &value) noexcept |
Encodes a string using Percent Encoding according to RFC 3986. | |
std::string | percent_decode (const std::string &value) noexcept |
Decodes a Percent-Encoded string. | |
std::string | to_upper_case (std::string str) |
Converts a string to uppercase. | |
std::string | to_lower_case (std::string str) |
Converts a string to lowercase. | |
std::string | extract_protocol (const std::string &url) |
Extracts the protocol from a URL. | |
std::string | remove_ws_prefix (const std::string &url) |
Removes the first occurrence of "wss://" or "ws://" from the given URL. | |
bool | is_valid_scheme (const std::string &url, const std::string &scheme) |
Checks if a given URL starts with a specified scheme. | |
bool | is_valid_domain (const std::string &domain) |
Validates if a domain name is correctly formatted. | |
bool | is_valid_path (const std::string &path) |
Checks if a path is correctly formatted. | |
bool | is_valid_query (const std::string &query) |
Validates if a query string is correctly formatted. | |
bool | is_valid_url (const std::string &url, const std::vector< std::string > &protocol) |
Validates if a URL is correctly formatted. | |
std::string | convert_user_agent_to_sec_ch_ua (const std::string &user_agent) |
Converts a User-Agent string to a sec-ch-ua header value. | |
const std::error_category & | websocket_error_category () |
Returns the singleton instance of the WebSocket error category. | |
std::error_code | make_error_code (WebSocketError e) |
Constructs an std::error_code from a WebSocketError. | |
using kurlyk::utils::CaseInsensitiveCookieMultimap = std::unordered_multimap<std::string, Cookie, CaseInsensitiveHash, CaseInsensitiveEqual> |
A case-insensitive unordered multimap specifically for storing HTTP cookies.
Definition at line 55 of file CaseInsensitiveMultimap.hpp.
using kurlyk::utils::CaseInsensitiveMultimap = std::unordered_multimap<std::string, std::string, CaseInsensitiveHash, CaseInsensitiveEqual> |
A case-insensitive unordered multimap for storing HTTP headers.
Definition at line 52 of file CaseInsensitiveMultimap.hpp.
|
strong |
Defines errors related to the internal state or lifecycle of the HTTP/WebSocket client.
Definition at line 12 of file ClientErrorCategory.hpp.
|
strong |
Represents protocol-level WebSocket errors.
Definition at line 12 of file WebSocketErrorCategory.hpp.
|
inlinenoexcept |
Compares two strings case-insensitively.
str1 | First string to compare. |
str2 | Second string to compare. |
true
if strings are equal ignoring case, otherwise false
. Definition at line 14 of file CaseInsensitiveMultimap.hpp.
|
inline |
Returns the singleton instance of the ClientErrorCategory.
Definition at line 48 of file ClientErrorCategory.hpp.
std::string kurlyk::utils::convert_user_agent_to_sec_ch_ua | ( | const std::string & | user_agent | ) |
Converts a User-Agent string to a sec-ch-ua header value.
user_agent | The User-Agent string. |
Definition at line 13 of file user_agent_utils.hpp.
|
inline |
Extracts the protocol from a URL.
url | The URL string. |
Definition at line 13 of file url_utils.hpp.
std::string kurlyk::utils::get_exec_dir | ( | ) |
Retrieves the directory of the executable file.
Definition at line 16 of file path_utils.hpp.
|
inline |
Checks whether the given error code belongs to the HTTP error category.
ec | The error code to check. |
Definition at line 46 of file HttpErrorCategory.hpp.
bool kurlyk::utils::is_valid_domain | ( | const std::string & | domain | ) |
Validates if a domain name is correctly formatted.
domain | The domain string to validate. |
Definition at line 62 of file url_utils.hpp.
bool kurlyk::utils::is_valid_email_id | ( | const std::string & | str | ) |
Validates an email address format.
str | The email address to validate. |
Definition at line 13 of file email_utils.hpp.
bool kurlyk::utils::is_valid_path | ( | const std::string & | path | ) |
Checks if a path is correctly formatted.
path | The path string to validate. |
Definition at line 89 of file url_utils.hpp.
bool kurlyk::utils::is_valid_query | ( | const std::string & | query | ) |
Validates if a query string is correctly formatted.
query | The query string to validate. |
Definition at line 102 of file url_utils.hpp.
bool kurlyk::utils::is_valid_scheme | ( | const std::string & | url, |
const std::string & | scheme ) |
Checks if a given URL starts with a specified scheme.
url | The URL string to check. |
scheme | The scheme (e.g., "http") to check. |
Definition at line 55 of file url_utils.hpp.
bool kurlyk::utils::is_valid_url | ( | const std::string & | url, |
const std::vector< std::string > & | protocol ) |
Validates if a URL is correctly formatted.
url | The URL string to validate. |
protocol | A vector of valid protocol schemes. |
Definition at line 126 of file url_utils.hpp.
|
inline |
Creates a std::error_code from a ClientError value.
e | ClientError enum value. |
Definition at line 56 of file ClientErrorCategory.hpp.
|
inline |
Creates an std::error_code from a CURLcode, allowing CURL errors to be used with the std::error_code API.
e | The CURL error code. |
Definition at line 31 of file CurlErrorCategory.hpp.
|
inline |
Constructs an std::error_code from a WebSocketError.
Definition at line 56 of file WebSocketErrorCategory.hpp.
|
inline |
Creates an std::error_code from an HTTP status code.
status_code | The HTTP status code (e.g., 404, 500). |
Definition at line 38 of file HttpErrorCategory.hpp.
Cookies kurlyk::utils::parse_cookie | ( | std::string | cookie | ) |
Parses a cookie string into a Cookies object.
cookie | The cookie string to parse. |
Definition at line 138 of file http_parser.hpp.
|
inline |
Parses a header pair from a buffer.
buffer | The buffer containing the header. |
size | The size of the buffer. |
key | Output parameter for the header key. |
value | Output parameter for the header value. |
Definition at line 15 of file http_parser.hpp.
|
noexcept |
Decodes a Percent-Encoded string.
value | The percent-encoded string to be decoded. |
Definition at line 39 of file percent_encoding.hpp.
|
noexcept |
Encodes a string using Percent Encoding according to RFC 3986.
value | The string to be encoded. |
Definition at line 17 of file percent_encoding.hpp.
std::string kurlyk::utils::remove_http_prefix | ( | const std::string & | url | ) |
Removes the first occurrence of "https://" or "http://" from the given URL.
url | The URL from which to remove the substring. |
Definition at line 13 of file http_utils.hpp.
std::string kurlyk::utils::remove_ws_prefix | ( | const std::string & | url | ) |
Removes the first occurrence of "wss://" or "ws://" from the given URL.
url | The URL from which to remove the substring. |
Definition at line 27 of file url_utils.hpp.
std::string kurlyk::utils::to_cookie_string | ( | const CaseInsensitiveMultimap & | cookies | ) |
Converts a CaseInsensitiveMultimap to a string format suitable for HTTP Cookie headers.
cookies | The multimap containing key-value pairs. |
Definition at line 98 of file http_parser.hpp.
std::string kurlyk::utils::to_cookie_string | ( | const Cookies & | cookies | ) |
Converts a CaseInsensitiveMultimap to a string format suitable for HTTP Cookie headers.
cookies | The multimap containing key-value pairs. |
Definition at line 114 of file http_parser.hpp.
|
inline |
Converts a string to lowercase.
str | Input string. |
Definition at line 26 of file string_utils.hpp.
|
noexcept |
Converts a map of query parameters into a URL query string.
query | The multimap containing query fields and values. |
prefix | Optional prefix for the query string. |
Definition at line 76 of file http_parser.hpp.
|
inline |
Converts a string to uppercase.
str | Input string. |
Definition at line 16 of file string_utils.hpp.
|
inline |
Returns the singleton instance of the WebSocket error category.
Definition at line 50 of file WebSocketErrorCategory.hpp.