On Thu, 2021-01-21 at 12:20 +0000, Hari Iyer wrote: > Hi, > I have filenames with non-ascii characters and this is the code that > enables me to encode it in my multipart request: > MultipartEntityBuilder.create().setCharset(StandardCharsets.UTF_8).se > tLaxMode(); > While this generates the content disposition (for filename Mädchen) > correctly as: > Content-Disposition: form-data; name="M[0xc3][0xa4]dchen.pdf"; > filename="M[0xc3][0xa4]dchen.pdf" > It also generates content type with a charset parameter like so: > Content-Type: multipart/form-data; boundary=eUBOAfgS- > JvSxb2ok4HhwTdwyKWzloz27CnQ0; charset=UTF-8 > This request fails with IIS as noted by many others (61384 – Adding > charset to multipart/form-data content type irritates IIS > (apache.org)<https://bz.apache.org/bugzilla/show_bug.cgi?id=61384>;). > How do I get around this? Removing the charset prevents the encoding > of the filename, adding it breaks IIS. I am using httpclient 4.5.11. > Thanks, > Hari. > >
Hari This is a bug in IIS and it should be fixed in IIS. One can suppress the charset parameter in Content-Type header like that but then one cannot have non-ascii characters in body part headers. ``` HttpEntity httpEntity = MultipartEntityBuilder.create() .setContentType(ContentType.create("multipart/form-data", (Charset) null)) .build(); System.out.println(httpEntity.getContentType()); ``` Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org