Bug 63710 - HTTP 304 NOT MODIFIED should not set Content-Length
Summary: HTTP 304 NOT MODIFIED should not set Content-Length
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.24
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2019-08-30 12:15 UTC by Boris Petrov
Modified: 2019-09-12 20:06 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Boris Petrov 2019-08-30 12:15:22 UTC
Tomcat seems to set the `Content-Length` header to 0 when the HTTP response code is 304 (Not Modified). This should not be done. Some references:

Comment 1 Mark Thomas 2019-08-30 17:58:58 UTC
The default servlet does not do this.

Tomcat does not do this if a Servlet returns a 304 response.

An application may well do this but that would be an application issue.
Comment 2 Boris Petrov 2019-08-30 18:53:03 UTC
Is it possible that the default Tomcat configuration adds this header?

When I run our integration tests (which use the embedded Tomcat), this header is not present in these responses. However, in production the header is there.

How do I debug who adds it?
Comment 3 Mark Thomas 2019-08-30 18:55:22 UTC
That is a question for the users mailing list.
Comment 4 Boris Petrov 2019-09-12 16:54:49 UTC
As noted in a mailing list message:


This happens only on HTTP/2 and is indeed a Tomcat bug.
Comment 5 Mark Thomas 2019-09-12 20:06:40 UTC
Fixed in:
- master for 9.0.25 onwards
- 8.5.x for 8.5.46 onwards