Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid updating Content-Length header in a 304 response.
I observed the following problem: `Transfer-Encoding` and `Content-Length` headers should be mutually exclusive and because I use chunked transfer, the `Transfer-Encoding` header is set in the response while the `Content-Length` header is not. In case of a 304 during a revalidation, the header contains Content-Length=0. Probably a proxy is responsible for this, just like the comment "Some well-known proxies respond with Content-Length=0, when returning 304" in the method CachedHttpResponseGenerator::addMissingContentLengthHeader is saying. In CacheEntryUpdater::mergeHeaders the Content-Length=0 is merged into the cached entry, but the cached entry contains also a `Transfer-Encoding` header, so in the cached entry these headers aren't mutually exclusive anymore. Because of the `Transfer-Encoding` header the method CachedHttpResponseGenerator::addMissingContentLengthHeader isn't fixing the `Content-Length` header and Content-Length=0 causes returning null instead of the cached content. IMHO the `Content-Length` header should not be merged into the cached response in case of a 304, at least if the cached entry contains a `Transfer-Encoding` header.
- Loading branch information