Login  Register

[jira] [Commented] (OFBIZ-4337) HttpClient does not support UTF-8

Posted by Nicolas Malin (Jira) on Jul 11, 2011; 9:37pm
URL: http://ofbiz.116.s1.nabble.com/jira-Created-OFBIZ-4337-HttpClient-does-not-support-UTF-8-tp3658997p3660938.html


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

Scott Gray commented on OFBIZ-4337:
-----------------------------------

A better approach would probably be something like this:
{code}
            if (method.equalsIgnoreCase("post")) {
                OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream(), this.streamCharSet != null ? this.streamCharSet : "UTF-8");
                if (Debug.verboseOn() || debug) Debug.log("Opened output stream", module);

                if (arguments != null) {
                    out.write(arguments);
                    if (Debug.verboseOn() || debug) Debug.log("Wrote arguements (parameters) : " + arguments, module);
                }
{code}
then just add the field streamCharSet (String) and a public setter method for it to address Adrian's concern.  The above approach is consistent with classes like MacroScreenViewHandler and requires less code by delegating the encoding to the Writer.

GET method requests shouldn't require this fix since the arguments string is url encoded already.

> HttpClient does not support UTF-8
> ---------------------------------
>
>                 Key: OFBIZ-4337
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4337
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: SVN trunk
>         Environment: Ubuntu
>            Reporter: Chatree Srichart
>            Priority: Critical
>         Attachments: HttpClient.patch, HttpClient.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I tried to send XML message includes Thai character using HttpClient.post(stream) method but the receiver got an unexpect character replaced to the Thai character has been sent. If I encode the stream using UTF-8 then it works fine.
> I have attached the patch file to solve this problem. Please commit the patch if it is useful for OFBiz.
> Regards,
> Chatree Srichart

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira