hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (HTTPCLIENT-1533) MultipartEntity encoding regression bug
Date Fri, 01 Aug 2014 10:49:38 GMT

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

Oleg Kalnichevski resolved HTTPCLIENT-1533.

    Resolution: Invalid

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
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"),

HttpEntity reqEntity = MultipartEntityBuilder.create()
        .addPart("tbl-id-parameter", tblId)
        .addPart("tbl-file-parameter", data)

ByteArrayOutputStream out = new ByteArrayOutputStream();
System.out.print(new String(out.toByteArray(), Consts.UTF_8));

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

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


> 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"),
> 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

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message