You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Chris Geer <ch...@cxtsoftware.com> on 2013/05/24 05:18:38 UTC

Disable chunked encoding on HTTP4 component

Is there a way to disable using chunked encoding on the HTTP4 component? I
have a server that apparently doesn't like chunked messages. I was able to
switch to use the HTTP component but I know that is eventually going to go
away.

I tried setting the CamelHttpChunked header to false but that doesn't seem
to be used by the Producer code.

I'm using Camel 2.10.4

Thanks,
Chris

Re: Disable chunked encoding on HTTP4 component

Posted by Christian Müller <ch...@gmail.com>.
Applied (with a small modification)! Thanks Chris!

Best,
Christian

Christian Müller
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Mon, May 27, 2013 at 10:40 PM, Chris Geer <ch...@cxtsoftware.com> wrote:

> On Sun, May 26, 2013 at 2:46 PM, Christian Müller <
> christian.mueller@gmail.com> wrote:
>
> > Hey Chris!
> >
> > I checked the API docs at [1]. It looks like you are using HTTP/1.1 and
> > your entity content length is unknown. Can you confirm this? Any chance
> to
> > determine the content length?
> >
>
> I do know the content length and was trying to set it, but it was being
> ignored. After digging in deeper I realized that the FilterStrategy for
> HTTP4 was stripping off any content-length headers from the exchange so
> there was no way to set it. Plus, in the HttpEntityConverter, the content
> length was always being set to -1. To fix this, I modified the
> HttpEntityConverter to use the length of the data passed in if the payload
> is a byte array (known length) and after doing that it didn't use chunked
> mode and everything is happy.
>
> The ticket is CAMEL-6402 [1] and I've uploaded a patch. I didn't modify
> anything for a body that is an InputStream since I wasn't sure if we could
> guarantee that the available() method would be accurate.
>
> Chris
>
> [1] https://issues.apache.org/jira/browse/CAMEL-6402
>
> >
> > [1]
> >
> >
> http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/entity/AbstractHttpEntity.html#setChunked%28boolean%29
> >
> >
> > Best,
> >
> > Christian Müller
> > -----------------
> >
> > Software Integration Specialist
> >
> > Apache Camel committer: https://camel.apache.org/team
> > V.P. Apache Camel: https://www.apache.org/foundation/
> > Apache Member: https://www.apache.org/foundation/members.html
> >
> > https://www.linkedin.com/pub/christian-mueller/11/551/642
> >
> >
> > On Fri, May 24, 2013 at 5:18 AM, Chris Geer <ch...@cxtsoftware.com>
> wrote:
> >
> > > Is there a way to disable using chunked encoding on the HTTP4
> component?
> > I
> > > have a server that apparently doesn't like chunked messages. I was able
> > to
> > > switch to use the HTTP component but I know that is eventually going to
> > go
> > > away.
> > >
> > > I tried setting the CamelHttpChunked header to false but that doesn't
> > seem
> > > to be used by the Producer code.
> > >
> > > I'm using Camel 2.10.4
> > >
> > > Thanks,
> > > Chris
> > >
> >
>

Re: Disable chunked encoding on HTTP4 component

Posted by Chris Geer <ch...@cxtsoftware.com>.
On Sun, May 26, 2013 at 2:46 PM, Christian Müller <
christian.mueller@gmail.com> wrote:

> Hey Chris!
>
> I checked the API docs at [1]. It looks like you are using HTTP/1.1 and
> your entity content length is unknown. Can you confirm this? Any chance to
> determine the content length?
>

I do know the content length and was trying to set it, but it was being
ignored. After digging in deeper I realized that the FilterStrategy for
HTTP4 was stripping off any content-length headers from the exchange so
there was no way to set it. Plus, in the HttpEntityConverter, the content
length was always being set to -1. To fix this, I modified the
HttpEntityConverter to use the length of the data passed in if the payload
is a byte array (known length) and after doing that it didn't use chunked
mode and everything is happy.

The ticket is CAMEL-6402 [1] and I've uploaded a patch. I didn't modify
anything for a body that is an InputStream since I wasn't sure if we could
guarantee that the available() method would be accurate.

Chris

[1] https://issues.apache.org/jira/browse/CAMEL-6402

>
> [1]
>
> http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/entity/AbstractHttpEntity.html#setChunked%28boolean%29
>
>
> Best,
>
> Christian Müller
> -----------------
>
> Software Integration Specialist
>
> Apache Camel committer: https://camel.apache.org/team
> V.P. Apache Camel: https://www.apache.org/foundation/
> Apache Member: https://www.apache.org/foundation/members.html
>
> https://www.linkedin.com/pub/christian-mueller/11/551/642
>
>
> On Fri, May 24, 2013 at 5:18 AM, Chris Geer <ch...@cxtsoftware.com> wrote:
>
> > Is there a way to disable using chunked encoding on the HTTP4 component?
> I
> > have a server that apparently doesn't like chunked messages. I was able
> to
> > switch to use the HTTP component but I know that is eventually going to
> go
> > away.
> >
> > I tried setting the CamelHttpChunked header to false but that doesn't
> seem
> > to be used by the Producer code.
> >
> > I'm using Camel 2.10.4
> >
> > Thanks,
> > Chris
> >
>

Re: Disable chunked encoding on HTTP4 component

Posted by Christian Müller <ch...@gmail.com>.
Hey Chris!

I checked the API docs at [1]. It looks like you are using HTTP/1.1 and
your entity content length is unknown. Can you confirm this? Any chance to
determine the content length?

[1]
http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/entity/AbstractHttpEntity.html#setChunked%28boolean%29


Best,

Christian Müller
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Fri, May 24, 2013 at 5:18 AM, Chris Geer <ch...@cxtsoftware.com> wrote:

> Is there a way to disable using chunked encoding on the HTTP4 component? I
> have a server that apparently doesn't like chunked messages. I was able to
> switch to use the HTTP component but I know that is eventually going to go
> away.
>
> I tried setting the CamelHttpChunked header to false but that doesn't seem
> to be used by the Producer code.
>
> I'm using Camel 2.10.4
>
> Thanks,
> Chris
>