You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jeff Segal <je...@gmail.com> on 2012/04/06 20:16:20 UTC

Re: http4 Component not exposing HttpContext

All,

I dusted this one off after 5 months and created a patch for it at
https://issues.apache.org/jira/browse/CAMEL-4693. It's pretty
straightforward - I added a HttpContext to HttpComponent, HttpEndpoint and
HttpProducer which is determined from the "httpContext" or "httpContextRef"
parameters. If a HttpContext is specified in the URI, HttpProducer will use
it when executing the request; otherwise it will not. I also added
HttpContext to HttpReferenceParameterTest. Perhaps there are other tests
that should be added/modified for this feature but I wasn't sure.

Thanks,
Jeff

On Fri, Nov 18, 2011 at 12:53 PM, Jeff Segal <je...@gmail.com>wrote:

> Thanks Claus. I created https://issues.apache.org/jira/browse/CAMEL-4693 for
> this. I'll also see if I can roll my sleeves up and provide a patch for it.
>
>
> On Fri, Nov 18, 2011 at 3:28 AM, Claus Ibsen <cl...@gmail.com>wrote:
>
>> Hi
>>
>> Seems like a good idea to add support for that HttpContext.
>>
>> We love contributions
>> http://camel.apache.org/contributing.html
>>
>> So feel free to create a JIRA and if possible attach a patch as well.
>>
>>
>> On Thu, Nov 17, 2011 at 6:54 PM, Jeff Segal <je...@gmail.com>
>> wrote:
>> > Hi all,
>> >
>> > I have a technical problem as well as a related documentation issue to
>> > report. The technical problem is as follows:
>> >
>> > HttpComponents 4.x provides a facility to use a HttpContext for a given
>> > request by calling HttpClient.execute(HttpUriRequest, HttpContext), but
>> it
>> > looks like the http4 Camel Component doesn't have hooks to use this.
>> > Looking at the latest source
>> > of org.apache.camel.component.http4.HttpProducer, I only see one way of
>> > calling HttpClient.execute():
>> >
>> >    protected HttpResponse executeMethod(HttpUriRequest httpRequest)
>> throws
>> >> IOException {
>> >>         return httpClient.execute(httpRequest);
>> >>     }
>> >
>> >
>> > Perhaps this could be made available in a similar fashion
>> > to HttpClientConfigurer? (for example creating a HttpContextConfigurer)
>> >
>> > My particular symptom is that I'm unable to force the http4 component to
>> > use preemptive authentication, which relies on HttpContext in HttpClient
>> > 4.x. In HttpClient 3.x, this was made possible by the HttpClientParams
>> flag
>> > "authenticationPreemptive". However, it appears that this was removed
>> for
>> > 4.x in favor of using HttpContext because of security concerns.
>> >
>> > The documentation issue is that the http4 Component docs claim that the
>> > httpClient.authenticationPreemptive=true flag will work the same way it
>> > does for the http Component, but it does not. I saw the following error
>> > when I tried to do so:
>> >
>> > Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
>> >> resolve endpoint:
>> >>
>> https4://<my_endpoint>?httpClient.authenticationPreemptive=true&httpClientConfigurer=myHttpClientConfigurer
>> due
>> >> to: There are 1 parameters that couldn't be set on the endpoint. Check
>> the
>> >> uri if the parameters are spelt correctly and that they are properties
>> of
>> >> the endpoint. Unknown parameters=[{authenticationPreemptive=true}]
>> >
>> >
>> > So it looks to me like the http4 Component should be updated to support
>> > setting a HttpContext for requests and the documentation should also be
>> > updated to reflect this change between HttpClient 3.x and 4.x.
>> >
>> > Thanks,
>> > Jeff
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>
>