Loading src/http/HttpProxyServer.cpp +17 −2 Changes for src/http/HttpProxyServer.cpp: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -72,6 +72,21 @@ bool pathPrefixMatches(const std::string &url, const std::string &prefix) { // 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. // The upstream's Content-Type exactly as sent, parameters included. HttpResponse:: // getContentType() deliberately returns only the lowercased media type (everything before // ';'), which is right for matching but wrong for relaying: dropping "; charset=utf-8" broke // the Nextcloud desktop client, which rejects any 207 PROPFIND reply whose Content-Type // doesn't contain "application/xml; charset=utf-8" ("PROPFIND-Antwort ist nicht im // XML-Format"). Falls back to the media type only if no raw header value is present. std::string relayedContentType(const libhttppp::HttpResponse &res) { if (auto *hd = res.getHeaderData("content-type")) { if (auto *v = hd->getfirstValue()) { if (!v->getvalue().empty()) return v->getvalue(); } } return res.getContentType(); } std::string forwardedResponseState(int status, const std::string &reason) { if (!reason.empty()) return std::to_string(status) + " " + reason; Loading Loading @@ -646,7 +661,7 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int libhttppp::HttpResponse curres; std::string reason = streamResp.getState(); curres.setState(forwardedResponseState(rangeStatus, reason)); curres.setContentType(streamResp.getContentType()); curres.setContentType(relayedContentType(streamResp)); // Same idea as kResponseSkip below, minus content-encoding/vary -- // nothing else claims those here since compression is skipped outright, Loading Loading @@ -786,7 +801,7 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int // status line, so always lead with the numeric code ourselves. std::string reason = last->getState(); curres.setState(forwardedResponseState(status, reason)); curres.setContentType(last->getContentType()); curres.setContentType(relayedContentType(*last)); // Forward every upstream response header to the client except hop-by-hop // ones and the handful applyResponseCompression() owns exclusively below -- Loading Loading
src/http/HttpProxyServer.cpp +17 −2 Changes for src/http/HttpProxyServer.cpp: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -72,6 +72,21 @@ bool pathPrefixMatches(const std::string &url, const std::string &prefix) { // 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. // The upstream's Content-Type exactly as sent, parameters included. HttpResponse:: // getContentType() deliberately returns only the lowercased media type (everything before // ';'), which is right for matching but wrong for relaying: dropping "; charset=utf-8" broke // the Nextcloud desktop client, which rejects any 207 PROPFIND reply whose Content-Type // doesn't contain "application/xml; charset=utf-8" ("PROPFIND-Antwort ist nicht im // XML-Format"). Falls back to the media type only if no raw header value is present. std::string relayedContentType(const libhttppp::HttpResponse &res) { if (auto *hd = res.getHeaderData("content-type")) { if (auto *v = hd->getfirstValue()) { if (!v->getvalue().empty()) return v->getvalue(); } } return res.getContentType(); } std::string forwardedResponseState(int status, const std::string &reason) { if (!reason.empty()) return std::to_string(status) + " " + reason; Loading Loading @@ -646,7 +661,7 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int libhttppp::HttpResponse curres; std::string reason = streamResp.getState(); curres.setState(forwardedResponseState(rangeStatus, reason)); curres.setContentType(streamResp.getContentType()); curres.setContentType(relayedContentType(streamResp)); // Same idea as kResponseSkip below, minus content-encoding/vary -- // nothing else claims those here since compression is skipped outright, Loading Loading @@ -786,7 +801,7 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int // status line, so always lead with the numeric code ourselves. std::string reason = last->getState(); curres.setState(forwardedResponseState(status, reason)); curres.setContentType(last->getContentType()); curres.setContentType(relayedContentType(*last)); // Forward every upstream response header to the client except hop-by-hop // ones and the handful applyResponseCompression() owns exclusively below -- Loading