Fix forwarding with space in url by encoding (#2155)

This commit is contained in:
Muhammad 2024-09-13 04:46:06 +03:00 committed by GitHub
parent 73406d1225
commit 93d8fb425d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -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));

View File

@ -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)
@ -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_;