You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Ahmed Ashour <as...@yahoo.com> on 2007/10/23 16:06:39 UTC

UTF-8 encoding of MultipartRequestEntity

Dear all,
 
On trying to upload a file whose name contains UTF-8 characters in Windows, the server side reads question marks instead, below is the code used.
 
However, it works fine when submitting the request from IE7.
 
Any idea about how to change the encoding?
 
Thanks a lot for your help.
 
-Ahmed
 
----------------------------------------------------------------------------------
        File f = ........;
        PostMethod filePost = new PostMethod("http://localhost/url/upload");
        Part[] parts = {new FilePart(f.getName(), f)};
        filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));
        HttpClient client = new HttpClient();
        int status = client.executeMethod(filePost);

----------------------------------------------------------------------------------

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: UTF-8 encoding of MultipartRequestEntity

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2007-10-23 at 07:06 -0700, Ahmed Ashour wrote: 
> Dear all,
>  
> On trying to upload a file whose name contains UTF-8 characters in Windows, the server side reads question marks instead, below is the code used.
>  
> However, it works fine when submitting the request from IE7.
>  
> Any idea about how to change the encoding?
>  
> Thanks a lot for your help.
>  
> -Ahmed
>  
> ----------------------------------------------------------------------------------
>         File f = ........;
>         PostMethod filePost = new PostMethod("http://localhost/url/upload");
>         Part[] parts = {new FilePart(f.getName(), f)};
>         filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));
>         HttpClient client = new HttpClient();
>         int status = client.executeMethod(filePost);
> 
> ----------------------------------------------------------------------------------
> 

Ahmed

Is this related to the comment you posted to HTTPCLIENT-293? 

https://issues.apache.org/jira/browse/HTTPCLIENT-293#action_12537217  

Anyways, we are evaluating different options of providing an improved
support for multipart coded entities in HttpClient 4.0 including a
lenient (browser compatibility) mode. 

If you need to emulate non-standard browser behaviors posting multipart
coded entities with Httpclient 3.1 the only option you have is to
implement a custom RequestEntity

Hope this helps

Oleg

> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 


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