Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12911

gzip Content-Encoding problems after upgrading to Jetty 9.4.12

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      After upgrading to Jetty 9.4.12.v20180830, some tests stopped working:

      • org.apache.camel.component.jetty.JettyContentTypeTest.testContentTypeWithGZipEncoding(org.apache.camel.component.jetty.JettyContentTypeTest)
      • org.apache.camel.component.jetty.JettyImageFileTest.testImageContentWithGZip(org.apache.camel.component.jetty.JettyImageFileTest)
      • org.apache.camel.component.jetty.HttpGZipEncodingTest.testGzipProducerWithGzipData(org.apache.camel.component.jetty.HttpGZipEncodingTest)
      • org.apache.camel.component.jetty.HttpGZipEncodingTest.testGzipProxy(org.apache.camel.component.jetty.HttpGZipEncodingTest)
      • org.apache.camel.component.jetty.HttpGZipEncodingTest.testHttpProducerWithGzip(org.apache.camel.component.jetty.HttpGZipEncodingTest)

      I did some analysis on jetty side and the reason is exactly this commit for Jetty issue 1688 where this was added to jetty-server/src/main/java/org/eclipse/jetty/server/Request.java:

          private void extractContentParameters()
          {
              // Content cannot be encoded
              if (_metaData!=null && getHttpFields().contains(HttpHeader.CONTENT_ENCODING))
                  throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501,"Unsupported Content-Encoding");
      ...
      

      With Jetty 9.4.11, it's Camel that does gzip encoding (when creating http entity for httpclient 3) and decoding (when reading http body in org.apache.camel.http.common.DefaultHttpBinding#readRequest()).

      However, with 9.4.12, after org.apache.camel.http.common.DefaultHttpBinding#readRequest() has read the body, it calls org.apache.camel.http.common.DefaultHttpBinding#readHeaders() which also extracts parameters.
      Because parameters may be POSTed using application/x-www-form-urlencoded content type, Jetty really needs GZIP Handler.

      So far tests worked, because we didn't use application/x-www-form-urlencoded content type.

      I'm not sure how to solve, but maybe, org.apache.camel.http.common.DefaultHttpBinding#readRequest() should remove Content-Encoding: gzip header after reading body? IMO, gzip decoding should be done at "server side" and jetty is the server - so either it decodes gzip content (using configured org.eclipse.jetty.server.handler.gzip.GzipHandler) or it should not be aware of encoded body (thus camel should pass wrapped request with Content-Encoding header filtered.

      Attachments

        Issue Links

          Activity

            People

              ffang Freeman Yue Fang
              ggrzybek Grzegorz Grzybek
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: