Revert original path to its initial behavior (#2157)

This commit is contained in:
Muhammad 2024-09-17 06:54:33 +03:00 committed by GitHub
parent bbcad71458
commit 1b4653577f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 4 deletions

View File

@ -209,9 +209,7 @@ class HttpRequestImpl : public HttpRequest
const std::string &getOriginalPath() const override const std::string &getOriginalPath() const override
{ {
return originalPath_.empty() return originalPath_.empty() ? path_ : originalPath_;
? (originalPath_ = drogon::utils::urlEncode(path_))
: originalPath_;
} }
void setQuery(const char *start, const char *end) void setQuery(const char *start, const char *end)
@ -675,7 +673,10 @@ class HttpRequestImpl : public HttpRequest
HttpMethod previousMethod_{Invalid}; HttpMethod previousMethod_{Invalid};
Version version_{Version::kUnknown}; Version version_{Version::kUnknown};
std::string path_; std::string path_;
mutable std::string originalPath_; /// Contains the encoded `path_` if and only if `path_` is set in encoded
/// form. If path is in a normal form and needed no decoding, then this will
/// be empty, as we do not need to store a duplicate.
std::string originalPath_;
bool pathEncode_{true}; bool pathEncode_{true};
std::string_view matchedPathPattern_{""}; std::string_view matchedPathPattern_{""};
std::string query_; std::string query_;