Hi Marie-Jo, This is only true when the charset is passed with the StringPart constructor (for backwards compatability reasons). Calling setChartSet(null) will do what you want though.
Mike On 2/27/06, Plainecassagne, Marie Josephe <[EMAIL PROTECTED]> wrote: > Mike, > > With Httpclient 2.0, the setting on charset is applied whatever value you > provide. > With Httpclient 3.0, the setting is changed to US-ASCII when the value > applied is not "correct", for instance null or "ISO-8859-1". > > Thanks > > Marie-Jo > > -----Original Message----- > From: Michael Becke [mailto:[EMAIL PROTECTED] > Sent: vendredi 24 février 2006 15:29 > To: HttpClient Project > Subject: Re: HTTP CLIENT - Question regarding charset setting in > MultipartPostMethod > > Hi Marie-Jo, > > Sounds like you're referring to the multipart headers, is that correct? > Assuming so, you can can control the chartset parameter by using the FilePart > object directly. For example try: > > FilePart f = new FilePart(targetFile.getName(), targetFile); > > f.setChartSet(null); // remove the header > or > f.setCharSet("\"ISO-8859-1\""); // change the header to "ISO-8859-1" > > filePost.addPart(f); > > > Also, if you're going to use HttpClient 3.0 I would recommend moving away > from the MultipartPostMethod and using the PostMethod with the > MultipartRequestEntity instead. > > Mike > > On 2/24/06, Plainecassagne, Marie Josephe <[EMAIL PROTECTED]> wrote: > > I have 2 solutions that would work with this servlet : > > - remove the charset setting in the header > > - change the charset setting to ="ISO-8859-1" > > I don't know how I can make it. Can you help me? > > > > I have tested versions 2 and versions 3 of HTTPClient. Both of them > > send the same header : application/octet-stream; charset=ISO-8859-1 > > > > Thanks for your help. > > > > Best regards > > > > Marie-Jo Plainecassagne > > > > PS My code wirh HTTPClient 2.0.2 : > > > > File targetFile; > > String szURL; > > > > ... > > > > URL targetURL = new URL(szURL); > > MultipartPostMethod filePost = new MultipartPostMethod(); > > filePost.setPath(targetURL.getPath()); > > > > filePost.addParameter( > > targetFile.getName(), > > targetFile); > > > > HttpClient client = new HttpClient(); > > client.getState().setCredentials( > > null, > > targetURL.getHost(), > > new > > UsernamePasswordCredentials(atdmConnection.getUser(), > > atdmConnection.getPassword()) > > ); > > client.startSession(targetURL); > > int status = client.executeMethod(filePost); > > > > if (status != 200) { > > System.out.println(status + "\n" + > > filePost.getResponseBodyAsString()); > > throw new Exception("Unable to upload file. Error = " + > > filePost.getResponseBodyAsString()); > > } > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
