hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject MultipartEntityBuilder and Charset US-ASCII
Date Mon, 17 Apr 2017 20:50:43 GMT
Hello,
At JMeter we have a bug report (
https://bz.apache.org/bugzilla/show_bug.cgi?id=60800) related to Multipart
Form POST request

A user reports that he has an issue with a request created by JMeter due to
the presence in Request Headers of "charset=US-ASCII" at end of boundary in
Content-Type.

------------------------------------------------------------------------
POST http://localhost:8081/

POST data:
--5v5So93EEOXPO8DIg4kmR-vfmsbimn
Content-Disposition: form-data; name="toto"

titi
--5v5So93EEOXPO8DIg4kmR-vfmsbimn--


*Request Headers:*
Connection: keep-alive
Content-Length: 123
*Content-Type: multipart/form-data;
boundary=5v5So93EEOXPO8DIg4kmR-vfmsbimn; charset=US-ASCII*
Host: localhost:8081
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_121)

------------------------------------------------------------------------

The code is created through (
https://github.com/apache/jmeter/blob/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L1201
):

1/            MultipartEntityBuilder multipartEntityBuilder =
MultipartEntityBuilder.create();

2/ As not Content Type is set in GUI, we default to US-ASCII so call:
multipartEntityBuilder.setCharset("US-ASCII");

3/
multipartEntityBuilder.setLaxMode();

4/ For every parameter:
                StringBody stringBody = new StringBody(arg.getValue(),
ContentType.create("text/plain", charset));
                FormBodyPart formPart = FormBodyPartBuilder.create(
                        parameterName, stringBody).build();
                multipartEntityBuilder.addPart(formPart);

5/
            HttpEntity entity = multipartEntityBuilder.build();
            post.setEntity(entity);


So my questions are the following:
1/ Is it correct to add this charset part ?
2/ Could you point me to the reference part of RFC that mentions this ?
3/ Is it correct to avoid setting charset in this case in API which would
lead to such request instead ?



POST http://localhost:8081/

POST data:
--xjNHd_UhEEpqC2ZoFCpGRzYzHK90ljsdpfTr
Content-Disposition: form-data; name="toto"

titi
--xjNHd_UhEEpqC2ZoFCpGRzYzHK90ljsdpfTr--

Request Headers:
Connection: keep-alive
Content-Length: 135
Content-Type: multipart/form-data;
boundary=xjNHd_UhEEpqC2ZoFCpGRzYzHK90ljsdpfTr
Host: localhost:8081
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_121)


Thanks for your help
Regards
Philippe M.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message