Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.22.1
-
None
-
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
- causes
-
CAMEL-12914 camel-rest-swagger - Unit test fails after jetty upgrade
-
- Resolved
-