Add getOriginalPath function (#1620)
This commit is contained in:
parent
07726dfcab
commit
3263b78ec3
|
@ -211,6 +211,9 @@ class DROGON_EXPORT HttpRequest
|
|||
/// Get the path of the request.
|
||||
virtual const std::string &path() const = 0;
|
||||
|
||||
/// Get the original path of the request.(before url-decoding)
|
||||
virtual const std::string &getOriginalPath() const = 0;
|
||||
|
||||
/// Get the path of the request.
|
||||
const std::string &getPath() const
|
||||
{
|
||||
|
|
|
@ -553,6 +553,7 @@ void HttpRequestImpl::swap(HttpRequestImpl &that) noexcept
|
|||
swap(flagForParsingParameters_, that.flagForParsingParameters_);
|
||||
swap(matchedPathPattern_, that.matchedPathPattern_);
|
||||
swap(path_, that.path_);
|
||||
swap(originalPath_, that.originalPath_);
|
||||
swap(pathEncode_, that.pathEncode_);
|
||||
swap(query_, that.query_);
|
||||
swap(headers_, that.headers_);
|
||||
|
|
|
@ -60,6 +60,7 @@ class HttpRequestImpl : public HttpRequest
|
|||
cookies_.clear();
|
||||
flagForParsingParameters_ = false;
|
||||
path_.clear();
|
||||
originalPath_.clear();
|
||||
pathEncode_ = true;
|
||||
matchedPathPattern_ = "";
|
||||
query_.clear();
|
||||
|
@ -121,6 +122,7 @@ class HttpRequestImpl : public HttpRequest
|
|||
{
|
||||
if (utils::needUrlDecoding(start, end))
|
||||
{
|
||||
originalPath_.append(start, end);
|
||||
path_ = utils::urlDecode(start, end);
|
||||
}
|
||||
else
|
||||
|
@ -162,6 +164,11 @@ class HttpRequestImpl : public HttpRequest
|
|||
return path_;
|
||||
}
|
||||
|
||||
const std::string &getOriginalPath() const override
|
||||
{
|
||||
return originalPath_.empty() ? path_ : originalPath_;
|
||||
}
|
||||
|
||||
void setQuery(const char *start, const char *end)
|
||||
{
|
||||
query_.assign(start, end);
|
||||
|
@ -555,6 +562,7 @@ class HttpRequestImpl : public HttpRequest
|
|||
HttpMethod method_{Invalid};
|
||||
Version version_{Version::kUnknown};
|
||||
std::string path_;
|
||||
std::string originalPath_;
|
||||
bool pathEncode_{true};
|
||||
string_view matchedPathPattern_{""};
|
||||
std::string query_;
|
||||
|
|
Loading…
Reference in New Issue