Hi,

I have looked up some other components doing HTTP communication like 
camel-http4 and camel-cxf and these components do copy the headers. I also 
found a unit test for copying these headers, so I assume that the documented 
behavior is the expected one. Unfortunately this unit test contained a bug, so 
it didn't find the bug in the component. I created a JIRA bug 
(https://issues.apache.org/jira/browse/CAMEL-7363) and attached a rather 
trivial patch to it (one line for the test and one line for the component...).

Best regards
Stephan

-----Original Message-----
From: Siano, Stephan [mailto:[email protected]] 
Sent: Montag, 7. April 2014 15:17
To: [email protected]
Subject: Expected behaviour of camel-ahc component concerning headers

Hi,

The documentation of the camel-ahc component (http://camel.apache.org/ahc.html 
) says:

"Message Body

Camel will store the HTTP response from the external server on the OUT body. 
All headers from the IN message will be copied to the OUT message, so headers 
are preserved during routing. Additionally Camel will add the HTTP response 
headers as well to the OUT message headers."

However this is not how it is implemented:
A new (empty) DefaultMessage will be created in the 
DefaultAhcBinding.onStatusReceived() method by calling exchange.getOut(). 
Afterwards only the HTTP-Response and the incoming HTTP headers are set to the 
out message. I discussed this with Aki Yoshida and he believes that the 
implemented behavior is the correct one as otherwise request and response 
messages would be mixed.

>From my perspective both approaches make sense, however the documentation and 
>the implementation should match. So either the line 
>(exchange.getOut().setHeaders(exchange.getIn().getAllHeaders());) should be 
>added to the DefaultBinding.onStatusReceived() method, or the documentation 
>should be adapted like "... OUT body. Camel will replace the OUT message 
>headers by the HTTP response headers, so headers are not preserved during 
>routing."

What do you think.

Best regards
Stephan

Reply via email to