From 6be024bad1662dc6e9e8339cde747634155c69b5 Mon Sep 17 00:00:00 2001 From: Yundi339 Date: Sat, 10 Oct 2026 00:43:35 +0800 Subject: [PATCH] fix: preserve handler Content-Length on HEAD responses --- http/server/HttpHandler.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/http/server/HttpHandler.cpp b/http/server/HttpHandler.cpp index 477a8469c..e123c659c 100644 --- a/http/server/HttpHandler.cpp +++ b/http/server/HttpHandler.cpp @@ -799,8 +799,11 @@ int HttpHandler::GetSendData(char** data, size_t* len) { pResp->headers["Accept-Ranges"] = "bytes"; pResp->headers["Content-Length"] = hv::to_string(fc->st.st_size); } else { - pResp->headers["Content-Type"] = "text/html"; - pResp->headers["Content-Length"] = "0"; + // Preserve entity length set by handlers (RFC 9110 HEAD mirrors GET metadata). + if (pResp->headers.find("Content-Length") == pResp->headers.end()) { + pResp->headers["Content-Type"] = "text/html"; + pResp->headers["Content-Length"] = "0"; + } } state = SEND_DONE; goto return_nobody;