Hi Folks,

It appears that the Synapse NHTTP transport is not properly handling the
response messages that don't have a Content-Type header. Currently when the
Content-Type header is not present in a response message the following bit
of code is executed by the ClientWorker.

                // there is no response entity-body
                responseMsgCtx.setProperty(NhttpConstants.NO_ENTITY_BODY,
Boolean.TRUE);
                responseMsgCtx.setEnvelope(new
SOAP11Factory().getDefaultEnvelope());

As a result the service client will receive a response with an empty
payload.

HTTP specs [1] describe how to handle this kind of scenarios as follows.

*Any HTTP/1.1 message containing an entity-body SHOULD include a
> Content-Type header field defining the media type of that body. If and only
> if the media type is not given by a Content-Type field, the recipient MAY
> attempt to guess the media type via inspection of its content and/or the
> name extension(s) of the URI used to identify the resource. If the media
> type remains unknown, the recipient SHOULD treat it as type
> "application/octet-stream". *
>

I propose that we should allow the user to specify a default content type
which will be used for the messages that don't have a content-type header.
If a default type is not specified by the user we can set set the
content-type to "application/octet-stream". WDYT?

Thanks,
Hiranya

[1] - http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1

-- 
Hiranya Jayathilaka
Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: [email protected];  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Reply via email to