Consider a http request response route:

from("jetty:http://localhost:8088/someService";).unmarshal().string().pro
cess(
           new Processor() { 
             public void process(Exchange e) { 
                   String input = (String) e.getIn().getBody();
                e.getOut().setBody(input + outputText); 
             }
           });

 
Currently, the unmarshaller copies the input message to the output
message and augments it. The copy brings with it all of the http
headers.
The result is that Content-Length from the request ends in the reply.
This breaks the http response[1].

One solution is to add a .removeHeader("Content-Length") to the route
but should that be necessary?
the header really belongs with the in message.

I am thinking that it never makes sense to copy a Content-Length header
from a HttpMessage but it would be wrong to remove it.

I am thinking that there should be a strategy for copying headers.

The Message.copyFrom() can call getCopyHeaders() which can in turn call
a strategy method pruneCopyHeaders() which for a HttpMessage override
can remove the Content-Length header.

Is this overkill or are there other cases where request headers just do
not make sense in a reply?


[1] https://issues.apache.org/activemq/browse/CAMEL-324


----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Reply via email to