[
https://issues.apache.org/jira/browse/HTTPCLIENT-1533?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henrik Alstad updated HTTPCLIENT-1533:
--------------------------------------
Description:
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);
was:
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.)
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);
> 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]