userver: userver/http/url.hpp Source File
Loading...
Searching...
No Matches
url.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/http/url.hpp
4/// @brief URL manipulation functions
5/// @ingroup userver_universal
6
7#include <map>
8#include <string>
9#include <string_view>
10#include <unordered_map>
11
12#include <userver/utils/impl/internal_tag_fwd.hpp>
13#include <userver/utils/str_icase.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace http {
18
19/// @brief Decode URL
20[[deprecated("Use a more strict http::parser::UrlDecode instead")]] std::string UrlDecode(std::string_view range);
21
22/// @brief Encode as URL
23std::string UrlEncode(std::string_view input_string);
24
27
28/// @brief Make an URL query
29std::string MakeQuery(const Args& query_args);
30
31/// @brief Make an URL query
32std::string MakeQuery(const std::unordered_map<std::string, std::string>& query_args);
33
34/// @brief Make an URL query
35std::string MakeQuery(std::initializer_list<std::pair<std::string_view, std::string_view>> query_args);
36
37/// @brief Make an URL with query arguments
38std::string MakeUrl(std::string_view path, const Args& query_args);
39
40/// @brief Make an URL with query arguments
41std::string MakeUrl(std::string_view path, const std::unordered_map<std::string, std::string>& query_args);
42
43/// @brief Make an URL with query arguments
44std::string MakeUrl(std::string_view path, const Args& query_args, MultiArgs query_multiargs);
45
46/// @brief Make an URL with query arguments
47std::string
48MakeUrl(std::string_view path, std::initializer_list<std::pair<std::string_view, std::string_view>> query_args);
49
50/// @brief Returns URL part before the first '?' character
51std::string ExtractMetaTypeFromUrl(const std::string& url);
52
53/// @brief Returns HTTP path part of a URL
54std::string ExtractPath(std::string_view url);
55
56/// @brief Returns hostname part of a URL
57std::string ExtractHostname(std::string_view url);
58
59namespace impl {
60
61std::string UrlDecode(utils::impl::InternalTag, std::string_view range);
62
63} // namespace impl
64
65} // namespace http
66
67USERVER_NAMESPACE_END