8 std::string original =
"Hello World! How are you?";
16 std::vector<std::string> emails = {
"valid@example.com",
"invalid-email",
"user@domain.ruf"};
17 for (
const auto& email : emails) {
18 KURLYK_PRINT <<
"Email: " << email <<
" is valid: " << std::boolalpha
23 std::string url =
"https://example.com/path?query=value";
25 KURLYK_PRINT <<
"Protocol in URL: " << protocol << std::endl;
30 KURLYK_PRINT <<
"Query string: " << query_string << std::endl;
33 std::string domain =
"example.com";
34 std::string path =
"/valid/path";
35 KURLYK_PRINT <<
"Domain " << domain <<
" is valid: " << std::boolalpha
37 KURLYK_PRINT <<
"Path " << path <<
" is valid: " << std::boolalpha
41 std::vector<std::string> protocols = {
"http",
"https"};
42 KURLYK_PRINT <<
"URL " << url <<
" is valid: " << std::boolalpha
46 std::string user_agent =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36";
48 KURLYK_PRINT <<
"sec-ch-ua header: " << sec_ch_ua << std::endl;
52 KURLYK_PRINT <<
"Executable path: " << exe_path << std::endl;
54 }
catch (
const std::exception& e) {
Main header file for the Kurlyk library, providing HTTP and WebSocket support.
std::string percent_decode(const std::string &value) noexcept
Decodes a Percent-Encoded string.
bool is_valid_url(const std::string &url, const std::vector< std::string > &protocol)
Validates if a URL is correctly formatted.
bool is_valid_email_id(const std::string &str)
Validates an email address format.
std::string extract_protocol(const std::string &url)
Extracts the protocol from a URL.
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.
bool is_valid_path(const std::string &path)
Checks if a path 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.
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.
bool is_valid_domain(const std::string &domain)
Validates if a domain name is correctly formatted.
utils::CaseInsensitiveMultimap QueryParams
Alias for query parameters in HTTP requests, stored case-insensitively.