From 7d0df29686bfc8da36eda223fabfb88de3e3e677 Mon Sep 17 00:00:00 2001 From: Baolin Zhu Date: Sun, 5 Apr 2026 13:51:29 +0800 Subject: [PATCH 1/2] Do not update Content-Length from 304 responses RFC 9111 Section 3.2 explicitly excludes Content-Length from the header fields that a cache MUST add to a stored response when updating it from a 304. Some broken servers send Content-Length: 0 in 304 responses, which replaces the correct stored Content-Length and causes clients to receive an empty body. --- src/HttpHeader.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 3f5db81ad55..2ccf9ecc70f 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -393,7 +393,11 @@ HttpHeader::skipUpdateHeader(const Http::HdrType id) const return // TODO: Consider updating Vary headers after comparing the magnitude of // the required changes (and/or cache losses) with compliance gains. - (id == Http::HdrType::VARY); + (id == Http::HdrType::VARY) || + // RFC 9111 Section 3.2 explicitly excludes Content-Length + // from the "MUST add ..., replacing already present" list. Also, + // broken servers are known to send Content-Length:0 in their 304s. + (id == Http::HdrType::CONTENT_LENGTH); } void From 030e2b22e46306f41e6f6ffc28eda8bffccfa13e Mon Sep 17 00:00:00 2001 From: Baolin Zhu Date: Sun, 5 Apr 2026 23:17:20 +0800 Subject: [PATCH 2/2] Add Baolin Zhu to CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index d6abfdf5cb5..a830af2c168 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -73,6 +73,7 @@ Thank you! Assar Westerlund Axel Westerhold Aymeric Vincent + Baolin Zhu Barry Dobyns Ben Kallus Benjamin Kerensa