You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cgiera <ch...@mic-cust.com> on 2015/02/25 13:57:03 UTC

Camel Netty Http: HttpHeaders case sensitive

Hello,

we are implementing a http camel route for receiving data from SAP.
The route consumes from a netty-http endpoint(from("netty-http...")).

Our tests with SoapUi worked fine, but when we tried sending data from the
SAP system the test failed with http 400 bad request.
After some research I found https://issues.apache.org/jira/browse/CAMEL-6599
where is mentioned to check if the host appears as http header.

I analyzed the http requests:
SoapUI:
 Accept-Encoding: gzip,deflate[\r][\n]
 Content-Type: text/xml;charset=UTF-8[\r][\n]
 Content-Length: 4[\r][\n]
 *Host: host-123:8080[\r][\n]*
 Connection: Keep-Alive[\r][\n]
 User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]

SAP:
    content-type: text/xml; charset=utf-8\r\n
    content-length: 3391\r\n
        [Content length: 3391]
    connection: keep-alive\r\n
    accept-encoding: gzip, deflate\r\n
    user-agent: SAP NetWeaver Application Server (1.0;731)\r\n
   * host: host-123:8080\r\n*
    sap-language: D\r\n

The camel netty http component checks if a "Host" http header exists(case
sensitive), SAP sends "host":
org.apache.camel.component.netty.http.handlers.HttpServerChannelHandler: 
 // must include HOST header as required by HTTP 1.1
if (!request.headers().names().contains(HttpHeaders.Names.HOST)) {
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, BAD_REQUEST);
response.setChunked(false);
response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
response.headers().set(Exchange.CONTENT_LENGTH, 0);
response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
messageEvent.getChannel().write(response).syncUninterruptibly();
messageEvent.getChannel().close();
return;
}

HttpHeaders can be/have to be case insensitive, see
http://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive
or http://www.ietf.org/rfc/rfc2616.txt.

Should I create a ticket for this?

kind regards,
soilworker



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Netty-Http-HttpHeaders-case-sensitive-tp5763157.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Netty Http: HttpHeaders case sensitive

Posted by cgiera <ch...@mic-cust.com>.
Thx for the quick response and solution.

kind regards,
Christoph



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Netty-Http-HttpHeaders-case-sensitive-tp5763157p5763231.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Netty Http: HttpHeaders case sensitive

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

There is indeed a bug, names() should be removed so we work directly
on the netty http headers
https://issues.apache.org/jira/browse/CAMEL-8411

On Thu, Feb 26, 2015 at 1:23 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> netty http headers is case insensitive, so the check for contains
> should work whether you use Host or host or HOST etc.
>
> So it may be the SAP system that cannot deal with host header defined
> using a upper case H.
>
> On Wed, Feb 25, 2015 at 1:57 PM, cgiera <ch...@mic-cust.com> wrote:
>> Hello,
>>
>> we are implementing a http camel route for receiving data from SAP.
>> The route consumes from a netty-http endpoint(from("netty-http...")).
>>
>> Our tests with SoapUi worked fine, but when we tried sending data from the
>> SAP system the test failed with http 400 bad request.
>> After some research I found https://issues.apache.org/jira/browse/CAMEL-6599
>> where is mentioned to check if the host appears as http header.
>>
>> I analyzed the http requests:
>> SoapUI:
>>  Accept-Encoding: gzip,deflate[\r][\n]
>>  Content-Type: text/xml;charset=UTF-8[\r][\n]
>>  Content-Length: 4[\r][\n]
>>  *Host: host-123:8080[\r][\n]*
>>  Connection: Keep-Alive[\r][\n]
>>  User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]
>>
>> SAP:
>>     content-type: text/xml; charset=utf-8\r\n
>>     content-length: 3391\r\n
>>         [Content length: 3391]
>>     connection: keep-alive\r\n
>>     accept-encoding: gzip, deflate\r\n
>>     user-agent: SAP NetWeaver Application Server (1.0;731)\r\n
>>    * host: host-123:8080\r\n*
>>     sap-language: D\r\n
>>
>> The camel netty http component checks if a "Host" http header exists(case
>> sensitive), SAP sends "host":
>> org.apache.camel.component.netty.http.handlers.HttpServerChannelHandler:
>>  // must include HOST header as required by HTTP 1.1
>> if (!request.headers().names().contains(HttpHeaders.Names.HOST)) {
>> HttpResponse response = new DefaultHttpResponse(HTTP_1_1, BAD_REQUEST);
>> response.setChunked(false);
>> response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
>> response.headers().set(Exchange.CONTENT_LENGTH, 0);
>> response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
>> messageEvent.getChannel().write(response).syncUninterruptibly();
>> messageEvent.getChannel().close();
>> return;
>> }
>>
>> HttpHeaders can be/have to be case insensitive, see
>> http://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive
>> or http://www.ietf.org/rfc/rfc2616.txt.
>>
>> Should I create a ticket for this?
>>
>> kind regards,
>> soilworker
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Camel-Netty-Http-HttpHeaders-case-sensitive-tp5763157.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Camel Netty Http: HttpHeaders case sensitive

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

netty http headers is case insensitive, so the check for contains
should work whether you use Host or host or HOST etc.

So it may be the SAP system that cannot deal with host header defined
using a upper case H.

On Wed, Feb 25, 2015 at 1:57 PM, cgiera <ch...@mic-cust.com> wrote:
> Hello,
>
> we are implementing a http camel route for receiving data from SAP.
> The route consumes from a netty-http endpoint(from("netty-http...")).
>
> Our tests with SoapUi worked fine, but when we tried sending data from the
> SAP system the test failed with http 400 bad request.
> After some research I found https://issues.apache.org/jira/browse/CAMEL-6599
> where is mentioned to check if the host appears as http header.
>
> I analyzed the http requests:
> SoapUI:
>  Accept-Encoding: gzip,deflate[\r][\n]
>  Content-Type: text/xml;charset=UTF-8[\r][\n]
>  Content-Length: 4[\r][\n]
>  *Host: host-123:8080[\r][\n]*
>  Connection: Keep-Alive[\r][\n]
>  User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]
>
> SAP:
>     content-type: text/xml; charset=utf-8\r\n
>     content-length: 3391\r\n
>         [Content length: 3391]
>     connection: keep-alive\r\n
>     accept-encoding: gzip, deflate\r\n
>     user-agent: SAP NetWeaver Application Server (1.0;731)\r\n
>    * host: host-123:8080\r\n*
>     sap-language: D\r\n
>
> The camel netty http component checks if a "Host" http header exists(case
> sensitive), SAP sends "host":
> org.apache.camel.component.netty.http.handlers.HttpServerChannelHandler:
>  // must include HOST header as required by HTTP 1.1
> if (!request.headers().names().contains(HttpHeaders.Names.HOST)) {
> HttpResponse response = new DefaultHttpResponse(HTTP_1_1, BAD_REQUEST);
> response.setChunked(false);
> response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
> response.headers().set(Exchange.CONTENT_LENGTH, 0);
> response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
> messageEvent.getChannel().write(response).syncUninterruptibly();
> messageEvent.getChannel().close();
> return;
> }
>
> HttpHeaders can be/have to be case insensitive, see
> http://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive
> or http://www.ietf.org/rfc/rfc2616.txt.
>
> Should I create a ticket for this?
>
> kind regards,
> soilworker
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Netty-Http-HttpHeaders-case-sensitive-tp5763157.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Camel Netty Http: HttpHeaders case sensitive

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Well spotted. Yeah you are welcome to log a ticket. And also we love
contributions so a patch with a fix is also welcome.
http://camel.apache.org/contributing.html

On Wed, Feb 25, 2015 at 1:57 PM, cgiera <ch...@mic-cust.com> wrote:
> Hello,
>
> we are implementing a http camel route for receiving data from SAP.
> The route consumes from a netty-http endpoint(from("netty-http...")).
>
> Our tests with SoapUi worked fine, but when we tried sending data from the
> SAP system the test failed with http 400 bad request.
> After some research I found https://issues.apache.org/jira/browse/CAMEL-6599
> where is mentioned to check if the host appears as http header.
>
> I analyzed the http requests:
> SoapUI:
>  Accept-Encoding: gzip,deflate[\r][\n]
>  Content-Type: text/xml;charset=UTF-8[\r][\n]
>  Content-Length: 4[\r][\n]
>  *Host: host-123:8080[\r][\n]*
>  Connection: Keep-Alive[\r][\n]
>  User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]
>
> SAP:
>     content-type: text/xml; charset=utf-8\r\n
>     content-length: 3391\r\n
>         [Content length: 3391]
>     connection: keep-alive\r\n
>     accept-encoding: gzip, deflate\r\n
>     user-agent: SAP NetWeaver Application Server (1.0;731)\r\n
>    * host: host-123:8080\r\n*
>     sap-language: D\r\n
>
> The camel netty http component checks if a "Host" http header exists(case
> sensitive), SAP sends "host":
> org.apache.camel.component.netty.http.handlers.HttpServerChannelHandler:
>  // must include HOST header as required by HTTP 1.1
> if (!request.headers().names().contains(HttpHeaders.Names.HOST)) {
> HttpResponse response = new DefaultHttpResponse(HTTP_1_1, BAD_REQUEST);
> response.setChunked(false);
> response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
> response.headers().set(Exchange.CONTENT_LENGTH, 0);
> response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
> messageEvent.getChannel().write(response).syncUninterruptibly();
> messageEvent.getChannel().close();
> return;
> }
>
> HttpHeaders can be/have to be case insensitive, see
> http://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive
> or http://www.ietf.org/rfc/rfc2616.txt.
>
> Should I create a ticket for this?
>
> kind regards,
> soilworker
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Netty-Http-HttpHeaders-case-sensitive-tp5763157.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/