18namespace Azure {
namespace Core {
20 inline std::string FormatEncodedUrlQueryParameters(
21 std::map<std::string, std::string>
const& encodedQueryParameters)
25 if (!encodedQueryParameters.empty())
28 for (
const auto& q : encodedQueryParameters)
30 queryStr += separator + q.first +
'=' + q.second;
51 std::string m_encodedPath;
53 std::map<std::string, std::string> m_encodedQueryParameters;
55 std::string GetUrlWithoutQuery(
bool relative)
const;
63 void AppendQueryParameters(
const std::string& encodedQueryParameters);
72 static std::string
Decode(
const std::string& value);
85 static std::string
Encode(
const std::string& value,
const std::string& doNotEncodeSymbols =
"");
99 explicit Url(
const std::string& encodedUrl);
109 void SetScheme(
const std::string& scheme) { m_scheme = scheme; }
116 void SetHost(
const std::string& encodedHost) { m_host = encodedHost; }
123 void SetPort(uint16_t port) { m_port = port; }
130 void SetPath(
const std::string& encodedPath) { m_encodedPath = encodedPath; }
142 m_encodedQueryParameters = std::move(queryParameters);
154 if (!m_encodedPath.empty() && m_encodedPath.back() !=
'/')
156 m_encodedPath +=
'/';
158 m_encodedPath += encodedPath;
173 m_encodedQueryParameters[encodedKey] = encodedValue;
183 m_encodedQueryParameters.erase(encodedKey);
191 const std::string&
GetHost()
const {
return m_host; }
198 const std::string&
GetPath()
const {
return m_encodedPath; }
220 return m_encodedQueryParameters;
227 const std::string&
GetScheme()
const {
return m_scheme; }
A map<string, string> with case-insensitive key comparison.
Represents the location where a request will be performed.
Definition url.hpp:46
static std::string Encode(const std::string &value, const std::string &doNotEncodeSymbols="")
Encodes value by escaping characters to the form of HH where HH are hex digits.
Definition url.cpp:141
Url()
Constructs a new, empty URL object.
Definition url.hpp:91
void SetPort(uint16_t port)
Sets URL port.
Definition url.hpp:123
std::string GetAbsoluteUrl() const
Gets Scheme, host, path and query parameters.
Definition url.cpp:240
void RemoveQueryParameter(const std::string &encodedKey)
Removes an existing query parameter.
Definition url.hpp:181
const std::string & GetHost() const
Gets URL host.
Definition url.hpp:191
void AppendQueryParameter(const std::string &encodedKey, const std::string &encodedValue)
The value of a query parameter is expected to be non-URL-encoded and, by default, it will be encoded ...
Definition url.hpp:171
void SetScheme(const std::string &scheme)
Sets URL scheme.
Definition url.hpp:109
const std::string & GetScheme() const
Gets the URL scheme.
Definition url.hpp:227
void SetPath(const std::string &encodedPath)
Sets URL path.
Definition url.hpp:130
uint16_t GetPort() const
Gets the port number set for the URL.
Definition url.hpp:209
const std::string & GetPath() const
Gets the URL path.
Definition url.hpp:198
void SetQueryParameters(std::map< std::string, std::string > queryParameters)
Sets the query parameters from an existing query parameter map.
Definition url.hpp:139
std::string GetRelativeUrl() const
Gets the path and query parameters.
Definition url.cpp:234
std::map< std::string, std::string > GetQueryParameters() const
Gets a copy of the list of query parameters from the URL.
Definition url.hpp:218
static std::string Decode(const std::string &value)
Decodes value by transforming all escaped characters to it's non-encoded value.
Definition url.cpp:97
void SetHost(const std::string &encodedHost)
Sets URL host.
Definition url.hpp:116
void AppendPath(const std::string &encodedPath)
Appends an element of URL path.
Definition url.hpp:152
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57