Open Mis1eader-dev opened 2 months ago
void forwardRequest(const std::shared_ptr
req->setPath(req->getOriginalPath());
drogon::app().forward(std::move(req), std::move(callback), host);
}
int main() {
drogon::app().registerHandler("/forward", [](const drogon::HttpRequestPtr &req, std::function<void (const drogon::HttpResponsePtr &)> &&callback) {
std::string host = "http://example.com";
forwardRequest(req, std::move(callback), host);
});
// Start the Drogon application
drogon::app().run();
return 0;
} please check the code I am not understand properly but try this .
@ladaniprem the provided alternative solution does this, but I'm awaiting opinions of other maintainers as to whether we should alter request objects or alter the forward function itself.
Describe the bug Forwarding requests that contain spaces in the URL all fail to be resolved on the forwarded party. After manually replacing spaces with their escaped equivalences it worked.
Solution Perform URL escaping on the path before forwarding.
Alternative Solution Have it use
req->getOriginalPath()
instead ofreq->path()