You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kingolego <jo...@sovereignsense.com> on 2013/03/13 18:47:12 UTC

CXF proxy route creates multiple (two) user-agent HTTP headers

A CXF-based proxy route creates multiple (two) user-agent HTTP headers, which
causes error responses from the recipient server.

In a proxy scenario, Camel is sending two user-agent HTTP headers from the
outbound endpoint.
The first is from the incoming client (SoapUI in this case). Interestingly
enough, the in-bound endpoint has lower-cased the header name (HTTP header
names are supposed to be case-insensitive; see RFC2616 section 4.2 "Message
Headers" [1]).

    user-agent: Apache-HttpClient/4.1.1 (java 1.5)
    User-Agent: Apache CXF 2.6.3

In this (and most? all?) scenarios, Camel/CXF should preserve the original
user-agent if it exists and not add a new one. I suspect the root cause may
be the handling of HTTP headers in a case-sensitive manner.

While multiple headers with the same name is allowed by RFC2616 4.2 [1]
under _certain conditions_, many HTTP server implementations allow it for
only certain headers, e.g., Set-Cookie. Otherwise, they return an error
response. In this particular case, Microsoft-IIS/7.5 Microsoft-HTTPAPI/2.0
returns a 400 response code and includes the following text in the response:
"HTTP Error 400. The request has an invalid header name."

A workaround is to remove incoming headers in the route by adding:

    <removeHeader headerName="User-Agent" />
    <removeHeader headerName="user-agent" />
or 
    <removeHeaders pattern="CamelHttp*" />

Although this has the minor undesirable effect of losing the original
user-agent information.

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2



--
View this message in context: http://camel.465427.n5.nabble.com/CXF-proxy-route-creates-multiple-two-user-agent-HTTP-headers-tp5729137.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF proxy route creates multiple (two) user-agent HTTP headers

Posted by kingolego <jo...@sovereignsense.com>.
Camel 2.10.3 / CXF 2.6.3





--
View this message in context: http://camel.465427.n5.nabble.com/CXF-proxy-route-creates-multiple-two-user-agent-HTTP-headers-tp5729137p5729374.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF proxy route creates multiple (two) user-agent HTTP headers

Posted by Claus Ibsen <cl...@gmail.com>.
I logged a ticket
https://issues.apache.org/jira/browse/CAMEL-6171

What version of Camel do you use?
And what is your Camel route?
And I assume you use CXF 2.6.3.


On Wed, Mar 13, 2013 at 6:47 PM, kingolego <jo...@sovereignsense.com> wrote:
> A CXF-based proxy route creates multiple (two) user-agent HTTP headers, which
> causes error responses from the recipient server.
>
> In a proxy scenario, Camel is sending two user-agent HTTP headers from the
> outbound endpoint.
> The first is from the incoming client (SoapUI in this case). Interestingly
> enough, the in-bound endpoint has lower-cased the header name (HTTP header
> names are supposed to be case-insensitive; see RFC2616 section 4.2 "Message
> Headers" [1]).
>
>     user-agent: Apache-HttpClient/4.1.1 (java 1.5)
>     User-Agent: Apache CXF 2.6.3
>
> In this (and most? all?) scenarios, Camel/CXF should preserve the original
> user-agent if it exists and not add a new one. I suspect the root cause may
> be the handling of HTTP headers in a case-sensitive manner.
>
> While multiple headers with the same name is allowed by RFC2616 4.2 [1]
> under _certain conditions_, many HTTP server implementations allow it for
> only certain headers, e.g., Set-Cookie. Otherwise, they return an error
> response. In this particular case, Microsoft-IIS/7.5 Microsoft-HTTPAPI/2.0
> returns a 400 response code and includes the following text in the response:
> "HTTP Error 400. The request has an invalid header name."
>
> A workaround is to remove incoming headers in the route by adding:
>
>     <removeHeader headerName="User-Agent" />
>     <removeHeader headerName="user-agent" />
> or
>     <removeHeaders pattern="CamelHttp*" />
>
> Although this has the minor undesirable effect of losing the original
> user-agent information.
>
> [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-proxy-route-creates-multiple-two-user-agent-HTTP-headers-tp5729137.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: CXF proxy route creates multiple (two) user-agent HTTP headers

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 13, 2013 at 6:47 PM, kingolego <jo...@sovereignsense.com> wrote:
> A CXF-based proxy route creates multiple (two) user-agent HTTP headers, which
> causes error responses from the recipient server.
>
> In a proxy scenario, Camel is sending two user-agent HTTP headers from the
> outbound endpoint.
> The first is from the incoming client (SoapUI in this case). Interestingly
> enough, the in-bound endpoint has lower-cased the header name (HTTP header
> names are supposed to be case-insensitive; see RFC2616 section 4.2 "Message
> Headers" [1]).
>
>     user-agent: Apache-HttpClient/4.1.1 (java 1.5)
>     User-Agent: Apache CXF 2.6.3
>
> In this (and most? all?) scenarios, Camel/CXF should preserve the original
> user-agent if it exists and not add a new one. I suspect the root cause may
> be the handling of HTTP headers in a case-sensitive manner.
>

Yeah that smells like a bug in camel-cxf / CXF.
Let me  log a JIRA ticket.


> While multiple headers with the same name is allowed by RFC2616 4.2 [1]
> under _certain conditions_, many HTTP server implementations allow it for
> only certain headers, e.g., Set-Cookie. Otherwise, they return an error
> response. In this particular case, Microsoft-IIS/7.5 Microsoft-HTTPAPI/2.0
> returns a 400 response code and includes the following text in the response:
> "HTTP Error 400. The request has an invalid header name."
>
> A workaround is to remove incoming headers in the route by adding:
>
>     <removeHeader headerName="User-Agent" />
>     <removeHeader headerName="user-agent" />
> or
>     <removeHeaders pattern="CamelHttp*" />
>
> Although this has the minor undesirable effect of losing the original
> user-agent information.
>
> [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-proxy-route-creates-multiple-two-user-agent-HTTP-headers-tp5729137.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen