Go to the documentation of this file.
17 #include <unordered_set>
19 namespace Azure {
namespace Core {
21 inline std::string FormatEncodedUrlQueryParameters(
22 std::map<std::string, std::string>
const& encodedQueryParameters)
26 if (!encodedQueryParameters.empty())
29 for (
const auto& q : encodedQueryParameters)
31 queryStr += separator + q.first +
'=' + q.second;
52 std::string m_encodedPath;
54 std::map<std::string, std::string> m_encodedQueryParameters;
58 const static std::unordered_set<unsigned char> defaultNonUrlEncodeChars;
60 std::string GetUrlWithoutQuery(
bool relative)
const;
68 void AppendQueryParameters(
const std::string& encodedQueryParameters);
77 static std::string
Decode(
const std::string& value);
90 static std::string
Encode(
const std::string& value,
const std::string& doNotEncodeSymbols =
"");
104 explicit Url(
const std::string& encodedUrl);
114 void SetScheme(
const std::string& scheme) { m_scheme = scheme; }
121 void SetHost(
const std::string& encodedHost) { m_host = encodedHost; }
128 void SetPort(uint16_t port) { m_port = port; }
135 void SetPath(
const std::string& encodedPath) { m_encodedPath = encodedPath; }
147 m_encodedQueryParameters = std::move(queryParameters);
159 if (!m_encodedPath.empty() && m_encodedPath.back() !=
'/')
161 m_encodedPath +=
'/';
163 m_encodedPath += encodedPath;
178 m_encodedQueryParameters[encodedKey] = encodedValue;
188 m_encodedQueryParameters.erase(encodedKey);
196 const std::string&
GetHost()
const {
return m_host; }
203 const std::string&
GetPath()
const {
return m_encodedPath; }
225 return m_encodedQueryParameters;
232 const std::string&
GetScheme()
const {
return m_scheme; }
const std::string & GetHost() const
Gets URL host.
Definition: url.hpp:196
uint16_t GetPort() const
Gets the port number set for the URL.
Definition: url.hpp:214
void SetQueryParameters(std::map< std::string, std::string > queryParameters)
Sets the query parameters from an existing query parameter map.
Definition: url.hpp:144
void RemoveQueryParameter(const std::string &encodedKey)
Removes an existing query parameter.
Definition: url.hpp:186
std::string GetRelativeUrl() const
Gets the path and query parameters.
Definition: url.cpp:211
void SetScheme(const std::string &scheme)
Sets URL scheme.
Definition: url.hpp:114
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:123
void AppendPath(const std::string &encodedPath)
Appends an element of URL path.
Definition: url.hpp:157
void SetHost(const std::string &encodedHost)
Sets URL host.
Definition: url.hpp:121
const std::string & GetPath() const
Gets the URL path.
Definition: url.hpp:203
const std::string & GetScheme() const
Gets the URL scheme.
Definition: url.hpp:232
Azure SDK abstractions.
Definition: azure_assert.hpp:55
static std::string Decode(const std::string &value)
Decodes value by transforming all escaped characters to it's non-encoded value.
Definition: url.cpp:79
void SetPort(uint16_t port)
Sets URL port.
Definition: url.hpp:128
A map<string, string> with case-insensitive key comparison.
Url()
Constructs a new, empty URL object.
Definition: url.hpp:96
void SetPath(const std::string &encodedPath)
Sets URL path.
Definition: url.hpp:135
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:176
std::map< std::string, std::string > GetQueryParameters() const
Gets a copy of the list of query parameters from the URL.
Definition: url.hpp:223
Represents the location where a request will be performed.
Definition: url.hpp:47
std::string GetAbsoluteUrl() const
Gets Scheme, host, path and query parameters.
Definition: url.cpp:217