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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
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


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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-4337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chatree Srichart updated OFBIZ-4337:
------------------------------------

    Attachment: HttpClient.patch

The patch file to encode the stream to UTF-8 before writing out.

> 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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-4337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chatree Srichart updated OFBIZ-4337:
------------------------------------

    Attachment: HttpClient.patch

> 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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Adrian Crum commented on OFBIZ-4337:
------------------------------------

It would be nice if the encoding was configurable, instead of hard-coding it to always be UTF-8.


> 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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Issue Comment Edited] (OFBIZ-4337) HttpClient does not support UTF-8

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Adrian Crum edited comment on OFBIZ-4337 at 7/11/11 9:06 AM:
-------------------------------------------------------------

It would be nice if the encoding was configurable, instead of hard-coding it to always be UTF-8. Also keep in mind that you can encode the data before using HttpClient.


      was (Author: [hidden email]):
    It would be nice if the encoding was configurable, instead of hard-coding it to always be UTF-8.

 

> 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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

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

Chatree Srichart commented on OFBIZ-4337:
-----------------------------------------

I have tried to encode the stream before posting but it didn't work.
This is my code:
...
...
Charset charset = Charset.forName("UTF-8");
String content = httpClient.post(new String(stream.getBytes(charset)));
...
...

Regards,
Chatree Srichart

> 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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ 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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-4337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chatree Srichart updated OFBIZ-4337:
------------------------------------

    Attachment:     (was: HttpClient.patch)

> 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
>   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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-4337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chatree Srichart updated OFBIZ-4337:
------------------------------------

    Attachment:     (was: HttpClient.patch)

> 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
>   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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-4337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chatree Srichart updated OFBIZ-4337:
------------------------------------

    Attachment: HttpClient.patch

Hi Scott,
Your approach is work fine for me. I re-attach a patch for that but I changed a bit for the variable's name. I see in the Java Doc for the OutputStreamWriter class use "charset" as lower case, http://download.oracle.com/javase/6/docs/api/java/io/OutputStreamWriter.html#OutputStreamWriter%28java.io.OutputStream,%20java.lang.String%29 . So, my patch is using "streamCharset" instead of "streamCharSet".

Regards,
Chatree Srichart

> 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
>
>   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

       
Reply | Threaded
Open this post in threaded view
|

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

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-4337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacques Le Roux closed OFBIZ-4337.
----------------------------------

    Assignee: Hans Bakker

> 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
>            Assignee: Hans Bakker
>            Priority: Critical
>             Fix For: SVN trunk
>
>         Attachments: 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