[ 
https://issues.apache.org/jira/browse/CAMEL-7246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14030569#comment-14030569
 ] 

Aki Yoshida edited comment on CAMEL-7246 at 6/13/14 12:31 PM:
--------------------------------------------------------------

Hi Sergey, Raul,
for SimpleBinding has the following response transfer code
    public Object populateCxfRsResponseFromExchange(org.apache.camel.Exchange 
camelExchange, Exchange cxfExchange) throws Exception {
        Object base = super.populateCxfRsResponseFromExchange(camelExchange, 
cxfExchange);
        return buildResponse(camelExchange, base);
    }

and this buildResponse(…) is making the difference in the behavior.
This buildResponse takes the plain response into a javax.ws.rs.core.Response 
using cxf's ResponseBuilder. Additionally, it is adding all the external 
headers like content-length (unless they are blocked by the header-stragety) to 
the builder. And this leads to those headers being later directly serialized 
into the response message.

So, I am wondering two things.

1. do we need this header insertion part there if it is not there in the 
default binding? (or at least setting the content-length there does not make 
sense when setting the content entity that doesn't match the content length).
2. if the headers are supposed to be added for SimpleBinding, can we do the 
consistency check in CXF to avoid this issue? In other words, what would be the 
desired behavior in the following case.

You are doing a plain cxf jaxrs without camel and building a response using the 
ResponseBuilder and inconsistently setting some properties, as

builder.entity("foo");
…
builder.header("Content-Length", "9")
…
builder.build()

Should this inconsistency be recognized in the builder itself to correct it and 
produce a consistent Response object?

regards, aki


was (Author: ay):
Hi Sergey,
for SimpleBinding has the following response transfer code
    public Object populateCxfRsResponseFromExchange(org.apache.camel.Exchange 
camelExchange, Exchange cxfExchange) throws Exception {
        Object base = super.populateCxfRsResponseFromExchange(camelExchange, 
cxfExchange);
        return buildResponse(camelExchange, base);
    }

and this buildResponse(…) is making the difference in the behavior.
This buildResponse takes the plain response into a javax.ws.rs.core.Response 
using cxf's ResponseBuilder. Additionally, it is adding all the external 
headers like content-length (unless they are blocked by the header-stragety) to 
the builder. And this leads to those headers being later directly serialized 
into the response message.

So, I am wondering two things.

1. do we need this header insertion part there if it is not there in the 
default binding? (or at least setting the content-length there does not make 
sense when setting the content entity that doesn't match the content length).
2. if the headers are supposed to be added for SimpleBinding, can we do the 
consistency check in CXF to avoid this issue? In other words, what would be the 
desired behavior in the following case.

You are doing a plain cxf jaxrs without camel and building a response using the 
ResponseBuilder and inconsistently setting some properties, as

builder.entity("foo");
…
builder.header("Content-Length", "9")
…
builder.build()

Should this inconsistency be recognized in the builder itself to correct it and 
produce a consistent Response object?

regards, aki

> [cxfrs] SimpleConsumer returns wrong Content-Type
> -------------------------------------------------
>
>                 Key: CAMEL-7246
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7246
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxf
>    Affects Versions: 2.12.2
>            Reporter: Alexey Markevich
>         Attachments: camel-cxfrs-content-type.zip
>
>
> Looks like Content-Type is taken from request



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to