hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jaydeep.fifadra" <jaydeep.fifa...@elitecore.com>
Subject HttpClient UTF-8 in multipart issue
Date Mon, 09 May 2011 11:39:13 GMT
Hello,

     I am using httpclient ( commons-httpclient-3.1 ) in my project and
very happy with it. But since last two weeks I stuck up with an issue as
describe bellow.

     On one my website which is compatible with UTF-8, I am uploading a
file with Postmethod and its work really very fine, but there are some
other text field other then file on that page for which I have to pass
values. When I am execute the method with other utf-8 character values
of those text field get corrupted. So please help me regarding this
issue. I need it really very fast.
      The code I am using is as bellow.

                                 postObj = new PostMethod(url);
                                 postObj.setRequestHeader(referer);


postObj.setRequestHeader(CharacterEncoding);

                                 ArrayList<Part>  parts = new
ArrayList<Part>();

                                  FilePart fpart = new
FilePart(fileAttribute.getAttributeName(), file);
                                  parts.add(new
FilePart(fileAttribute.getAttributeName(), file));

                                 for(String param:paraNames){
                                     JSONArray array =
jsonObj.optJSONArray(param);
//   param value that get corrupted
                                      StringPart spart = new
StringPart(param, jsonObj.getString(param),"UTF-8");
                                      spart.setContentType("text/plain;
charset=utf-8");
                                      spart.setCharSet("UTF-8");
                                      parts.add(spart);
                                 }

                                 postObj.setRequestEntity(new
MultipartRequestEntity(parts.toArray(new Part[0]), postObj.getParams()));

                                 int rtnStatus = 0;

                                 try{
                                     rtnStatus =
httpClient.executeMethod(postObj);
                                  }


     Thanks for read my problem.

     regards,
   Jaydeep Fifadra


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