Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-581

@GZIP annotation prevents setting HTTP headers in MessageBodyWriter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.3-beta-1
    • 2.2-beta-1, 2.2.RC1, 2.2.0.GA, 2.2.1, 2.2.2.GA
    • jaxrs

      I was testing upgrading RESTeasy from v2.0.1.GA to v2.2.2.GA and discovered a problem with the @GZIP annotation in builds since 2.2-beta-1 (when CommitHeaderOutputStream.java was introduced). We have a MessageBodyWriter implemented for a custom data type, and in the writeTo() method we add a new HTTP header. When using the @GZIP annotation on the method and querying the REST API using a client which sends Accept-Encoding: gzip, we are finding that any headers added in our MessageBodyWriter are not included in the response.

      I stepped through in the debugger, and found that this sequence seems to be the issue:

      • In GZIPEncodingInterceptor.write, creates new EndableGZIPOutputStream wrapping the CommitHeaderOutputStream.
      • EndableGZIPOutputStream calls super constructor GZIPOutputStream.
      • GZIPOutputStream constructor calls GZIPOutputStream.writeHeader().
      • GZIPOutputStream.writeHeader calls out.write(byte[]).
      • CommitHeaderOutputStream.write(byte[]) calls the commit callback which writes the current headers to the response.
      • GZIPEncodingInterceptor calls context.proceed(), which calls into our MessageBodyWriter.writeTo() method, but any headers added at this point are ignored because they have already been committed to the response.

              patriot1burke@gmail.com Bill Burke (Inactive)
              pkwarren_jira Philip Warren (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: