Loading src/http/HttpProxyServer.cpp +18 −3 Changes for src/http/HttpProxyServer.cpp: 18 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -76,6 +76,21 @@ bool pathPrefixMatches(const std::string &url, const std::string &prefix) { return url[prefix.size()] == '/'; } // HTTP/2 and HTTP/3 only carry the numeric :status pseudo-header, so their // HttpResponse objects have no reason phrase to reuse when ProxyPlus serves an // HTTP/1 client. Supply the standard phrases for statuses ProxyPlus commonly // sees from asynchronous and temporarily-unavailable upstreams. A reason // phrase is optional in HTTP/1, so unknown codes remain forwardable as-is. std::string forwardedResponseState(int status, const std::string &reason) { if (!reason.empty()) return std::to_string(status) + " " + reason; switch (status) { case 202: return HTTP202; case 503: return HTTP503; default: return std::to_string(status); } } netplus::TlsTrustPolicy trustPolicyFor(const store::HttpRouteRecord &route) { netplus::TlsTrustPolicy policy; policy.verifyPeer = route.tlsVerifyUpstream; Loading Loading @@ -357,7 +372,8 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int if (!matched.upstreamPool.empty()) { auto picked = _loadBalancer.pick(matched.upstreamPool, sourceIp); if (!picked) { sendError(curreq, HTTP502, "upstream pool '" + matched.upstreamPool + "' has no targets"); sendError(curreq, HTTP503, "upstream pool '" + matched.upstreamPool + "' has no available targets"); return; } pickedTarget = *picked; Loading Loading @@ -464,8 +480,7 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int // (e.g. "OK", see HttpResponse::parse) would drop the code from our own // status line, so always lead with the numeric code ourselves. std::string reason = last->getState(); curres.setState(reason.empty() ? std::to_string(status) : std::to_string(status) + " " + reason); curres.setState(forwardedResponseState(status, reason)); curres.setContentType(last->getContentType()); // Forward every upstream response header to the client except hop-by-hop Loading Loading
src/http/HttpProxyServer.cpp +18 −3 Changes for src/http/HttpProxyServer.cpp: 18 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -76,6 +76,21 @@ bool pathPrefixMatches(const std::string &url, const std::string &prefix) { return url[prefix.size()] == '/'; } // HTTP/2 and HTTP/3 only carry the numeric :status pseudo-header, so their // HttpResponse objects have no reason phrase to reuse when ProxyPlus serves an // HTTP/1 client. Supply the standard phrases for statuses ProxyPlus commonly // sees from asynchronous and temporarily-unavailable upstreams. A reason // phrase is optional in HTTP/1, so unknown codes remain forwardable as-is. std::string forwardedResponseState(int status, const std::string &reason) { if (!reason.empty()) return std::to_string(status) + " " + reason; switch (status) { case 202: return HTTP202; case 503: return HTTP503; default: return std::to_string(status); } } netplus::TlsTrustPolicy trustPolicyFor(const store::HttpRouteRecord &route) { netplus::TlsTrustPolicy policy; policy.verifyPeer = route.tlsVerifyUpstream; Loading Loading @@ -357,7 +372,8 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int if (!matched.upstreamPool.empty()) { auto picked = _loadBalancer.pick(matched.upstreamPool, sourceIp); if (!picked) { sendError(curreq, HTTP502, "upstream pool '" + matched.upstreamPool + "' has no targets"); sendError(curreq, HTTP503, "upstream pool '" + matched.upstreamPool + "' has no available targets"); return; } pickedTarget = *picked; Loading Loading @@ -464,8 +480,7 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int // (e.g. "OK", see HttpResponse::parse) would drop the code from our own // status line, so always lead with the numeric code ourselves. std::string reason = last->getState(); curres.setState(reason.empty() ? std::to_string(status) : std::to_string(status) + " " + reason); curres.setState(forwardedResponseState(status, reason)); curres.setContentType(last->getContentType()); // Forward every upstream response header to the client except hop-by-hop Loading