Bug 61384 - Adding charset to multipart/form-data content type irritates IIS
Summary: Adding charset to multipart/form-data content type irritates IIS
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 3.2
Hardware: All All
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
: 60800 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-08-05 17:41 UTC by Felix Schumacher
Modified: 2017-09-02 13:28 UTC (History)
2 users (show)



Attachments
Don't add charset to multipart/form-data content type (1.22 KB, patch)
2017-08-05 17:41 UTC, Felix Schumacher
Details | Diff
Alternative patch taking into account charset only if set (1.87 KB, patch)
2017-08-27 10:17 UTC, Philippe Mouawad
Details | Diff
Test plan showing issue with current nightly build as of 27 august 2017 (2.34 KB, application/xml)
2017-08-27 12:26 UTC, Philippe Mouawad
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Schumacher 2017-08-05 17:41:26 UTC
Created attachment 35202 [details]
Don't add charset to multipart/form-data content type

As reported by a few JMeter users on the users mailing list. IIS will not accept files that are send inside a multipart/form-data. It seems that the only difference between working (with other clients) and non-working (with JMeter) clients is the addition of a charset to the multipart/form-data content type.

It seems that akka-http had the same problems as reported on https://github.com/akka/akka-http/issues/338

The attached patch removes the charset on the multipart content-type. The entities that are part of the multipart will remain there charsets.
Comment 1 Philippe Mouawad 2017-08-07 12:39:10 UTC
Hi Felix, 
Is this issue related also to Bug 60800 ?
Thanks
Comment 2 Philippe Mouawad 2017-08-07 12:40:29 UTC
(In reply to Philippe Mouawad from comment #1)
> Hi Felix, 
> Is this issue related also to Bug 60800 ?
> Thanks

And also Bug 56141 ?
Comment 3 Felix Schumacher 2017-08-24 18:27:21 UTC
(In reply to Philippe Mouawad from comment #2)
> (In reply to Philippe Mouawad from comment #1)
> > Hi Felix, 
> > Is this issue related also to Bug 60800 ?
> > Thanks
> 
> And also Bug 56141 ?

Well 56141 looks related. And as comment 3 on that bug shows the same findings (it works better when the charset is not on the form-data), I think it is safe to apply this patch.
Comment 4 Felix Schumacher 2017-08-25 19:04:01 UTC
Will be included in version 3.3.

Date: Fri Aug 25 19:02:36 2017
New Revision: 1806215

URL: http://svn.apache.org/viewvc?rev=1806215&view=rev
Log:
Don't set the charset on enclosing multipart/form-data header. It irritates some servers.

The charset was added sometime back while refactoring to use a newer api of http client.
See https://bz.apache.org/bugzilla/show_bug.cgi?id=56141 for more info.

Bugzilla Id: 61384


Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/xdocs/changes.xml
Comment 5 Philippe Mouawad 2017-08-27 10:17:27 UTC
Created attachment 35258 [details]
Alternative patch taking into account charset only if set
Comment 6 Philippe Mouawad 2017-08-27 12:26:28 UTC
Created attachment 35259 [details]
Test plan showing issue with current nightly build as of 27 august 2017
Comment 7 Philippe Mouawad 2017-08-27 12:27:11 UTC
With attached plan, even If I have set UTF-8 charset, request sent corrupts file name:
POST http://localhost:8081/

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

titi
--grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl
Content-Disposition: form-data; name="chineseChar"

安
--grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl
Content-Disposition: form-data; name="test"; filename="?.jmx"
Content-Type: text/plain

<actual file content, not shown here>
--grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl--


[no cookies]

Request Headers:
Connection: keep-alive
Content-Length: 2768
Content-Type: multipart/form-data; boundary=grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl
Host: localhost:8081
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_112)
Comment 8 Philippe Mouawad 2017-08-27 12:29:39 UTC
*** Bug 60800 has been marked as a duplicate of this bug. ***
Comment 9 Philippe Mouawad 2017-08-27 12:41:36 UTC
Author: pmouawad
Date: Sun Aug 27 12:39:50 2017
New Revision: 1806358

URL: http://svn.apache.org/viewvc?rev=1806358&view=rev
Log:
Bug 61384 - Adding charset to multipart/form-data content type irritates IIS

Bugzilla Id: 61384

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Comment 10 Philippe Mouawad 2017-08-27 12:55:53 UTC
Author: pmouawad
Date: Sun Aug 27 12:54:56 2017
New Revision: 1806361

URL: http://svn.apache.org/viewvc?rev=1806361&view=rev
Log:
Bug 61384 - Adding charset to multipart/form-data content type irritates IIS
Fix failing tests
Bugzilla Id: 61384

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
Comment 11 Philippe Mouawad 2017-08-27 13:58:16 UTC
Author: pmouawad
Date: Sun Aug 27 13:44:44 2017
New Revision: 1806366

URL: http://svn.apache.org/viewvc?rev=1806366&view=rev
Log:
Bug 61384 - Adding charset to multipart/form-data content type irritates IIS
Fix failing test
Add test on param non corruption when charset is UTF-8
Bugzilla Id: 61384

Modified:
    jmeter/trunk/bin/testfiles/TEST_HTTP.jmx
    jmeter/trunk/bin/testfiles/TEST_HTTP_HttpClient4.csv
    jmeter/trunk/bin/testfiles/TEST_HTTP_HttpClient4.xml
    jmeter/trunk/bin/testfiles/TEST_HTTP_Java.csv
    jmeter/trunk/bin/testfiles/TEST_HTTP_Java.xml
Comment 12 Philippe Mouawad 2017-08-27 14:15:13 UTC
Author: pmouawad
Date: Sun Aug 27 14:14:36 2017
New Revision: 1806369

URL: http://svn.apache.org/viewvc?rev=1806369&view=rev
Log:
Bug 61384 - Adding charset to multipart/form-data content type irritates IIS
Fix failing test
Add test on param non corruption when charset is UTF-8 , second try
Bugzilla Id: 61384

Modified:
    jmeter/trunk/bin/testfiles/TEST_HTTP_HttpClient4.xml
    jmeter/trunk/bin/testfiles/TEST_HTTP_Java.xml
Comment 13 Philippe Mouawad 2017-08-27 17:49:37 UTC
Author: pmouawad
Date: Sun Aug 27 17:49:03 2017
New Revision: 1806384

URL: http://svn.apache.org/viewvc?rev=1806384&view=rev
Log:
Bug 61384 - Adding charset to multipart/form-data content type irritates IIS
Fix failing test:
- Java Implementation corrupts parameter name for UTF-8, so add a check
- Fix wrong CSV file for Java
Bugzilla Id: 61384

Modified:
    jmeter/trunk/bin/testfiles/TEST_HTTP.jmx
    jmeter/trunk/bin/testfiles/TEST_HTTP_Java.csv
Comment 14 Felix Schumacher 2017-08-27 18:08:19 UTC
(In reply to Philippe Mouawad from comment #7)
> With attached plan, even If I have set UTF-8 charset, request sent corrupts
> file name:
> POST http://localhost:8081/
> 
> POST data:
> --grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl
> Content-Disposition: form-data; name="toto"
> 
> titi
> --grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl
> Content-Disposition: form-data; name="chineseChar"
> 
> 安
> --grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl
> Content-Disposition: form-data; name="test"; filename="?.jmx"
> Content-Type: text/plain
> 
> <actual file content, not shown here>
> --grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl--
> 
> 
> [no cookies]
> 
> Request Headers:
> Connection: keep-alive
> Content-Length: 2768
> Content-Type: multipart/form-data;
> boundary=grIHU42M9gTheYA5QVpw9uJAi6UAsLd8_QhLl
> Host: localhost:8081
> User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_112)

The file name is part of the header and has to be encoded (using quoted printable) separately. It is another problem.
Comment 15 Philippe Mouawad 2017-09-02 13:28:36 UTC
Author: pmouawad
Date: Sat Sep  2 13:27:57 2017
New Revision: 1807047

URL: http://svn.apache.org/viewvc?rev=1807047&view=rev
Log:
Bug 61384 - Adding charset to multipart/form-data content type irritates IIS
Revert changes as per further analysis and jmeter/hc mailing lists answers
Bugzilla Id: 61384

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java