Jetty Producer always uses "Transfer-Encoding: chunked"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Jetty Producer always uses "Transfer-Encoding: chunked"

mluckam
When passing a request with a Content-Length header through a route with a jetty consumer and producer, the producer is removing the Content-Length header and replacing it with Transfer-Encoding: chunked.  The uri option chunked appears to only be for jetty consumers and not for producers.  This issue seems to stem from the following set of calls starting in JettyHttpProducer ln 184 (camel-2.18.2):

httpExchange.setRequestContent(is)
  this.request.content(new InputStreamContentProvider(ins), this.requestContentType)

With the content set as an InputStreamContentProvider, when the content.getLength() is called in org.eclipse.jetty.client.HttpConnection ln 120, it is returned as -1.  This causes the "Transfer-Encoding: chunked" header to be added at ln 129.  Again in the org.eclipse.jetty.http.HttpGenerator class getLength() is called on the InputStreamContentProvider and since it is -1, the Content-Length header is not added to the request to be sent out.

I propose that the InputStreamContentProvider be subclassed and given a value for its length as was done by the class org.eclipse.jetty.proxy.ProxyServlet.ProxyInputStreamContentProvider.  This subclass could then be used in the JettyHttpProducer, but only if the Content-Length header exists.  This would allow subsequent calls to the ContentProvider to return a positive value for getLength() and therefore allow the Content-Length header to persist.  A prototype of this patch is attached to the post.

jettyProducer.patch
 
Reply | Threaded
Open this post in threaded view
|

Re: Jetty Producer always uses "Transfer-Encoding: chunked"

Claus Ibsen-2
Hi

Have you tried your patch and then run all the unit tests of camel-jetty9 ?

On Fri, Mar 10, 2017 at 11:12 PM, mluckam <[hidden email]> wrote:

> When passing a request with a Content-Length header through a route with a
> jetty consumer and producer, the producer is removing the Content-Length
> header and replacing it with Transfer-Encoding: chunked.  The uri option
> chunked appears to only be for jetty consumers and not for producers.  This
> issue seems to stem from the following set of calls starting in
> JettyHttpProducer ln 184 (camel-2.18.2):
>
> httpExchange.setRequestContent(is)
>   this.request.content(new InputStreamContentProvider(ins),
> this.requestContentType)
>
> With the content set as an InputStreamContentProvider, when the
> content.getLength() is called in org.eclipse.jetty.client.HttpConnection ln
> 120, it is returned as -1.  This causes the "Transfer-Encoding: chunked"
> header to be added at ln 129.  Again in the
> org.eclipse.jetty.http.HttpGenerator class getLength() is called on the
> InputStreamContentProvider and since it is -1, the Content-Length header is
> not added to the request to be sent out.
>
> I propose that the InputStreamContentProvider be subclassed and given a
> value for its length as was done by the class
> org.eclipse.jetty.proxy.ProxyServlet.ProxyInputStreamContentProvider.  This
> subclass could then be used in the JettyHttpProducer, but only if the
> Content-Length header exists.  This would allow subsequent calls to the
> ContentProvider to return a positive value for getLength() and therefore
> allow the Content-Length header to persist.  A prototype of this patch is
> attached to the post.
>
> jettyProducer.patch
> <http://camel.465427.n5.nabble.com/file/n5795277/jettyProducer.patch>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Jetty-Producer-always-uses-Transfer-Encoding-chunked-tp5795277.html
> Sent from the Camel Development mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Jetty Producer always uses "Transfer-Encoding: chunked"

mluckam
Yes, the patch has been functionally tested and passes all the unit tests of camel-jetty9.
Reply | Threaded
Open this post in threaded view
|

Re: Jetty Producer always uses "Transfer-Encoding: chunked"

Claus Ibsen-2
Hi

Can you log a JIRA ticket and if possible provide a patch as github PR

On Sat, Mar 11, 2017 at 5:40 PM, mluckam <[hidden email]> wrote:
> Yes, the patch has been functionally tested and passes all the unit tests of
> camel-jetty9.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Jetty-Producer-always-uses-Transfer-Encoding-chunked-tp5795277p5795291.html
> Sent from the Camel Development mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2