[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1533?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Kalnichevski resolved HTTPCLIENT-1533.
-------------------------------------------

    Resolution: Invalid

Henrik,
If you are unsure whether or not the problem you are having may be a bug, 
please post your question to the user list and not to the issue tracker. Please 
also make sure that whatever bits of code you submit to support your assertion, 
they should not require any external dependencies besides HttpClient and should 
at least compile.

This piece of code produces well formed mime message as far as I can tell
{code:java}
StringBody tblId = new StringBody("bär", 
ContentType.TEXT_PLAIN.withCharset("UTF-8"));

ByteArrayBody data = new ByteArrayBody("bär".getBytes("UTF-8"), 
ContentType.TEXT_XML.withCharset("UTF-8"), "file");

HttpEntity reqEntity = MultipartEntityBuilder.create()
        .addPart("tbl-id-parameter", tblId)
        .addPart("tbl-file-parameter", data)
        .setCharset(Charset.forName("UTF-8"))
        .build();

ByteArrayOutputStream out = new ByteArrayOutputStream();
reqEntity.writeTo(out);
System.out.print(new String(out.toByteArray(), Consts.UTF_8));
{code}

{noformat}
--y3GRYta9h2UfOSo7Yl_IjONdwe0SGQ
Content-Disposition: form-data; name="tbl-id-parameter"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

bär
--y3GRYta9h2UfOSo7Yl_IjONdwe0SGQ
Content-Disposition: form-data; name="tbl-file-parameter"; filename="file"
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary

bär
--y3GRYta9h2UfOSo7Yl_IjONdwe0SGQ--
{noformat}
 
Oleg

> MultipartEntity encoding regression bug
> ---------------------------------------
>
>                 Key: HTTPCLIENT-1533
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1533
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient, HttpMime
>    Affects Versions: 4.3.4
>         Environment: Linux
>            Reporter: Henrik Alstad
>
> Not 100% sure if it's a bug, but in any case, the small code snippet below 
> works with version 4.3.1, but not the most recent 4.3.4
> (And when I say 4.3.4 doesen't work, I mean that it does compile, it does 
> run, it does fire off the request, but the server responds that there's 
> something wrong with the UTF-8 encoding... it seems like the receiving server 
> treats the content as ISO8859-1, so I suspect that for some reason, the 4.3.4 
> versions sets the encoding or something like that, differently than 4.3.1.)
> Is this a bug? Something must have changed at least, between 4.3.1 and 4.3.4. 
> I only changed versions and didnt touch the code.
> StringBody tblId = new StringBody(properties.getProperty("tbl-script-name"), 
> ContentType.TEXT_PLAIN.withCharset("UTF-8"));
> ByteArrayBody data = new ByteArrayBody(message.getBytes("UTF-8"), 
> ContentType.TEXT_XML.withCharset("UTF-8"), "file"); 
> HttpEntity reqEntity = MultipartEntityBuilder.create()
> .addPart(properties.getProperty("tbl-id-parameter"), tblId)
> .addPart(properties.getProperty("tbl-file-parameter"), data)
> .setCharset(Charset.forName("UTF-8"))
> .build();        
> post.setEntity(reqEntity);
> CloseableHttpResponse response = HttpClients.createDefault().execute(post);



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to