https://bz.apache.org/bugzilla/show_bug.cgi?id=63932

            Bug ID: 63932
           Summary: Content compression breaks contract of ETag
           Product: Tomcat 9
           Version: 9.0.x
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: micha...@apache.org
  Target Milestone: -----

This is basically the same as Bug 39727.

Consider a huge JSON file, content compression is on in the connector and this
simple servlet:

> protected void doGet(HttpServletRequest request, HttpServletResponse 
> response) throws ServletException, IOException {
>       response.setContentType("application/json");
>       Path dump = Paths.get("projects.json");
>       response.setContentLengthLong(Files.size(dump));
>       response.setHeader("ETag", String.format("\"%d+%s\"", Files.size(dump), 
> Files.getLastModifiedTime(dump)));
>       Files.copy(dump, response.getOutputStream());
> }

and the following curl requests:

> $ curl http://md11gxtc:8080/awesome/awesome  -H "Accept-Encoding: identity" -I
> HTTP/1.1 200
> ETag: "2571736354+2016-01-07T12:29:06.455824Z"
> vary: accept-encoding
> Content-Type: application/json
> Content-Length: 2571736354
> Date: Mon, 18 Nov 2019 11:50:04 GMT

This one is fine, now lets request compression:
> $ curl http://md11gxtc:8080/awesome/awesome  -H "Accept-Encoding: gzip" -I
> HTTP/1.1 200
> ETag: "2571736354+2016-01-07T12:29:06.455824Z"
> vary: accept-encoding
> Content-Encoding: gzip
> Content-Type: application/json
> Transfer-Encoding: chunked
> Date: Mon, 18 Nov 2019 11:50:46 GMT

RFC 7232, 2.1 + 2.3 + 2.3.1 + 2.3.3 say: ETag generation happens over content
negotiation.

RFC 7231, 5.3 these headers are part of content negotiation:
Accept
Accept-Charset
Accept-Encoding
Accept-Language

Basically, Tomcat would require to modify the ETag somehow and on the fly
remove the change when If-Match/If-None-Match arrives at the servlet. Fully
opaque.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to