fix(registry): keep the GET body for HEAD over Void::Net
Void::Net derives Content-Length from the response body and drops any explicit Content-Length header, so clearing the body in the bridge made HEAD responses report Content-Length: 0. Keep the body: the transport already suppresses it for HEAD while reporting the GET length.
This commit is contained in:
1 parent
76b15e79c4
commit
8fddffd127
1 file changed
+2
-5
@@ -227,17 +227,14 @@ Void::Result::Result<void, Void::Result::Error> HttpServer::start(const HttpServ
|
|||||||
}
|
}
|
||||||
bridged.body = request.body;
|
bridged.body = request.body;
|
||||||
|
|
||||||
// HEAD is routed exactly like GET; the body is dropped but Content-Length is preserved.
|
// HEAD is routed exactly like GET; the body stays so the transport can
|
||||||
|
// derive the GET Content-Length, and Void::Net suppresses the body itself.
|
||||||
const bool head_only = request.method == Void::Net::Method::Head;
|
const bool head_only = request.method == Void::Net::Method::Head;
|
||||||
if (head_only) {
|
if (head_only) {
|
||||||
bridged.method = "GET";
|
bridged.method = "GET";
|
||||||
}
|
}
|
||||||
HttpResponse response = handler(bridged);
|
HttpResponse response = handler(bridged);
|
||||||
apply_default_security_headers(response);
|
apply_default_security_headers(response);
|
||||||
if (head_only) {
|
|
||||||
response.headers["Content-Length"] = std::to_string(response.body.size());
|
|
||||||
response.body.clear();
|
|
||||||
}
|
|
||||||
Void::Net::ServerResponse net_response;
|
Void::Net::ServerResponse net_response;
|
||||||
net_response.status = response.status;
|
net_response.status = response.status;
|
||||||
for (const auto &[name, value] : response.headers) {
|
for (const auto &[name, value] : response.headers) {
|
||||||
|
|||||||
Reference in new issue
Block a user