From 1b4653577f09322cb3adea65ea98002c266e9626 Mon Sep 17 00:00:00 2001 From: Muhammad <73486659+Mis1eader-dev@users.noreply.github.com> Date: Tue, 17 Sep 2024 06:54:33 +0300 Subject: [PATCH] Revert original path to its initial behavior (#2157) --- lib/src/HttpRequestImpl.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/HttpRequestImpl.h b/lib/src/HttpRequestImpl.h index 95ae3d84..412aecf9 100644 --- a/lib/src/HttpRequestImpl.h +++ b/lib/src/HttpRequestImpl.h @@ -209,9 +209,7 @@ class HttpRequestImpl : public HttpRequest const std::string &getOriginalPath() const override { - return originalPath_.empty() - ? (originalPath_ = drogon::utils::urlEncode(path_)) - : originalPath_; + return originalPath_.empty() ? path_ : originalPath_; } void setQuery(const char *start, const char *end) @@ -675,7 +673,10 @@ class HttpRequestImpl : public HttpRequest HttpMethod previousMethod_{Invalid}; Version version_{Version::kUnknown}; 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}; std::string_view matchedPathPattern_{""}; std::string query_;