hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Krugler <kkrugler_li...@transpac.com>
Subject Re: French accents problem while sending postMethod
Date Tue, 22 Sep 2009 12:58:07 GMT
Hi Nicolas,

On Sep 22, 2009, at 2:35am, Nicolas Beucler wrote:

> Hi All,
>
> Seems that i have some problem to send parts containing non ascii
> characters using multi part post request.
>
> What i do is :
> [CODE]
> FilePartSource fileSource = new FilePartSource(f);
>            Part[] parts = { new StringPart("commandxml", commandxml,
> "UTF-8"),
>                    new FilePart("uploadFile", fileSource) };
> //            Part[] parts = { new StringPart("commandxml",  
> commandxml,
> "ISO-8859-1"),
> //                    new FilePart("uploadFile", fileSource) };
>            postMethode.setRequestEntity(new  
> MultipartRequestEntity(parts,
>                    postMethode.getParams()));
>            client = new HttpClient();
>            client.getHostConfiguration().setProxy(
>                    BatchBol.propMan.getProperty("proxyHost"),
>
> Integer.valueOf(BatchBol.propMan.getProperty("proxyPort")));
>
> client.getHttpConnectionManager().getParams().setConnectionTimeout(
>                    5000);
>            int status = client.executeMethod(postMethode);
> [/CODE]
> calling a web service sending multi part post.
>
> The first part consist in a xml formated string such as :
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <createdocument>
>    <authentication
> token 
> ="Cnk05awANGBw1epAOnApcPy3RueQCk_evrpBt0UPiLtVEmCKXL-5XSko71coaryt- 
> Lk8O_Yrz9e-BOn7NexdFA"/>
>    <workspace name="WorkspaceName" id="14058"/>
>    <category id="38181"/>
>    <parent id="14836645"/>
>    <attributes>
>        <attribute value="Test ADEX" name="TITLE"/>
>        <attribute value="Mes réf : 12345" name="REFERENCE"/>
>        <attribute value="12345" name="REVISION"/>
>        <attribute value="20/09/2009" name="DUE_DATE"/>
>    </attributes>
> </createdocument>
>
> and the second part is a file.
>
> See attached file to have a look at the code.
>
> What's happen is that the "Mes réf" thing becomes Mes r[0xc3][0xa9]f  
> and
> unfortunatly doesn't work with the server side.
>
> It seems that when HttpClient create the parts it re-encodes the  
> content
> (red and bold in the log trace):

[0xc3][0xa9] are the UTF-8 bytes required to represent é. I'm guessing  
the log output auto-displays non-7-bit-ascii text using hex codes, to  
avoid issues with terminals set to us-ascii.

Often problems like this are caused by server configuration - e.g.  
there are countless posts on the Solr mailing list about needing to  
configure Tomcat to treat incoming URLs as UTF-8.

-- Ken





--------------------------
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-210-6378


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message