I just captured the http request and response and found some thing interesting.
When camel-http send the request to back end server which is protected with 
HTTP Basic Authentication,  
HttpClient sends a request without Authentication inform first, then it sends 
the request with the Authentication header when it  get the 401 response.

If you just want to camel-http send the request with the Authentication header, 
you can set url like this.
from("direct:endpoint").to("http://localhost:8081?authMethod=Basic&authUsername=user1&authPassword=pwd&httpClient.authenticationPreemptive=true";);



--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Tuesday, October 29, 2013 at 5:13 PM, Willem jiang wrote:

> I did a quick test with the camel trunk ( I think it’s same with last camel 
> release 2.12.1), the HTTP Basic Authentication setting is work out of box.  
>  
> from("direct:endpoint").to("http://localhost:8081?authMethod=Basic&authUsername=user1&authPassword=pwd”);
>  
> I think you need to double check if the authPassword setting, It should be a 
> plaint text.  
>  
> --  
> Willem Jiang
>  
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
> (English)
> http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang  
> Weibo: 姜宁willem
>  
>  
>  
>  
>  
> On Tuesday, October 29, 2013 at 1:03 AM, martin11 wrote:
>  
> > Hi Christian,
> >  
> > I tried to use HTTP auth options:
> >  
> > .to("http://{{server}}:{{port}}/{{address}}?authMethod=Basic&authUsername={{user}}&authPassword={{password}}";)
> >  
> > But it fails again:
> >  
> > INFO - Basic authentication scheme selected
> > DEBUG - Took 1889 millis to send to:
> > Endpoint[http://172.24.40.110:5985/wsman?authMethod=Basic&authPassword=******&authUsername=Administrator]
> > INFO - basic authentication scheme selected
> > INFO - No credentials available for BASIC 'WSMAN'@172.24.40.110:5985
> > DEBUG - Took 45 millis to send to: Endpoint[http://172.24.40.110:5985/wsman]
> > ERROR - Failed delivery for (MessageId: ID-asgard-47899-1382979475336-0-11
> > on ExchangeId: ID-asgard-47899-1382979475336-0-9). Exhausted after delivery
> > attempt: 1 caught:
> > org.apache.camel.component.http.HttpOperationFailedException: HTTP operation
> > failed invoking http://172.24.40.110:5985/wsman with statusCode: 401
> >  
> >  
> >  
> > --
> > View this message in context: 
> > http://camel.465427.n5.nabble.com/HTTP-Basic-Authentication-tp5742229p5742320.html
> > Sent from the Camel - Users mailing list archive at Nabble.com 
> > (http://Nabble.com).
> >  
>  
>  



Reply via email to