Skip to content

Commit

Permalink
Fix forwarding with space in url by encoding (#2155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mis1eader-dev authored Sep 13, 2024
1 parent 73406d1 commit 93d8fb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/src/HttpAppFrameworkImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ void HttpAppFrameworkImpl::forward(
const std::string &hostString,
double timeout)
{
req->setPath(req->getOriginalPath());
if (hostString.empty())
{
HttpInternalForwardHelper::forward(req, std::move(callback));
Expand Down
6 changes: 4 additions & 2 deletions lib/src/HttpRequestImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ class HttpRequestImpl : public HttpRequest

const std::string &getOriginalPath() const override
{
return originalPath_.empty() ? path_ : originalPath_;
return originalPath_.empty()
? (originalPath_ = drogon::utils::urlEncode(path_))
: originalPath_;
}

void setQuery(const char *start, const char *end)
Expand Down Expand Up @@ -673,7 +675,7 @@ class HttpRequestImpl : public HttpRequest
HttpMethod previousMethod_{Invalid};
Version version_{Version::kUnknown};
std::string path_;
std::string originalPath_;
mutable std::string originalPath_;
bool pathEncode_{true};
std::string_view matchedPathPattern_{""};
std::string query_;
Expand Down

0 comments on commit 93d8fb4

Please sign in to comment.