-
-
Notifications
You must be signed in to change notification settings - Fork 508
Closed
Labels
bugSomething isn't workingSomething isn't workingquestionIssue can be closed by providing informationIssue can be closed by providing information
Description
I am working on a reverse-proxy server, I want to set the headers that i get after fetching the original server but it does not works. I receive 9 headers from original server but only 4 are added to current headers.
CROW_CATCHALL_ROUTE(Server)([](const crow::request& req, crow::response& res) {
string ip = get_server_ip(REQUEST_COUNT, IP_POOL);
auto op = fetch_response_from_ip(ip, req.raw_url, PORT);
if (op) {
res.code = op->status;
res.body = op->body;
if (req.raw_url != "/") {
for (const auto& header : op->headers) {
//std::cout << "Header: " << header.first << ": " << header.second << std::endl;
res.set_header(header.first, header.second);
}
}
// All headers set in the response are being logged correctly but they are not present when checked in the networks tab in dev tools
// and file contents are missing. I recive 9 headers from original server but only 4 are added to current headers 😢
std::cout << "Headers set in response:" << std::endl;
for (const auto& header : res.headers) {
std::cout << header.first << ": " << header.second << std::endl;
}
}
else {
res.code = 502; // Bad Gateway
res.write("Failed to forward request: Unexpected Error Occurred !");
}
res.set_header("BODY", op->body);
cout << endl << "BODY: === " << endl << op->body << endl;
res.end();
});
Ioannis-Markos-Angelidakis
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingquestionIssue can be closed by providing informationIssue can be closed by providing information