[ 
https://issues.apache.org/jira/browse/SYNAPSE-662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12883516#action_12883516
 ] 

Heshan Suriyaarachchi edited comment on SYNAPSE-662 at 6/29/10 7:40 AM:
------------------------------------------------------------------------

Hi, 
  I went throught the HTTP 1.0[1] and HTTP 1.1[2] specifications. It does not 
say whether to have a space between ";" and "charset" or not. Therefore we 
should support both the cases, where there is a space or no-space. I could not 
think of a reason why the ClientWorker uses following condition to set the 
CHARACTER_SET_ENCODING property. 

 responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, 
contentType.indexOf(HTTP.CHARSET_PARAM) > 0 ? charSetEnc : 
MessageContext.DEFAULT_CHAR_SET_ENCODING);

Furthermore, the ServerWorker does not follow this approach and straight away 
retrieves the CharSetEncoding and sets is as a property in the MessageContext. 
 
 String charSetEncoding = BuilderUtil.getCharSetEncoding(contentTypeStr);
 msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, 
charSetEncoding);

Attaching the patch herewith. 

[1] - http://www.w3.org/Protocols/HTTP/1.0/spec.html#Content-Type
[2] - http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17

      was (Author: heshan):
    Hi, 
  I went throught the HTTP 1.0[1] and HTTP 1.1[2] specifications. It does not 
say whether to have a space between ";" and "charset" or not. Therefore we 
should support both the cases, where there is a space or no-space. I could not 
think of a reason why the ClientWorker uses following condition to set the 
CHARACTER_SET_ENCODING property. 

 responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, 
contentType.indexOf(HTTP.CHARSET_PARAM) > 0 ? charSetEnc : 
MessageContext.DEFAULT_CHAR_SET_ENCODING);

Furthermore, the ServerWorker does not follow this approach and straight away 
retrieves the CharSetEncoding and sets is as a property in the MessageContext. 
 
 String charSetEncoding = BuilderUtil.getCharSetEncoding(contentTypeStr);
 msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, 
charSetEncoding);

[1] - http://www.w3.org/Protocols/HTTP/1.0/spec.html#Content-Type
[2] - http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
  
> ClientWorker overriding character encoding
> ------------------------------------------
>
>                 Key: SYNAPSE-662
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-662
>             Project: Synapse
>          Issue Type: Bug
>    Affects Versions: 1.2
>            Reporter: Myles Bunbury
>         Attachments: SYNAPSE-662-patch.txt
>
>
> The following code exists in the 
> org.apache.synapse.transport.nhttp.ClientWorker class' run() method:
>                 responseMsgCtx.setProperty(
>                     Constants.Configuration.CHARACTER_SET_ENCODING,
>                     contentType.indexOf(HTTP.CHARSET_PARAM) > 0 ?
>                         charSetEnc : 
> MessageContext.DEFAULT_CHAR_SET_ENCODING);
> This fails however for the following Content-Type HTTP header:
>   application/soap+xml; action="urn:echoResponse";charset=UTF-16
> BuilderUtil.getCharSetEncoding(contentType) is called a few lines up and 
> correctly extracts the UTF-16 character set value, but then overrides this 
> and sets it to UTF-8. It does this because the value of 
> org.apache.http.protocol.HTTP.CHARSET_PARAM is "; charset=". That is, it's 
> failing because the response does not have a space between the charset 
> parameter and the previous parameter.
> Reading through the HTTP specs, I haven't come across anything that says 
> either that whitespace is permissible or not permissible here. In my view the 
> code should therfore be flexible enough to handle either case. 
> I would suggest simpifying the code to:
>      
> responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, 
> charSetEnc);
> as the BuilderUtil.getCharSetEncoding() code above the offending code seems 
> to be sufficient at first glance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@synapse.apache.org
For additional commands, e-mail: dev-h...@synapse.apache.org

Reply via email to