You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/08/27 12:39:51 UTC

svn commit: r1806358 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java

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

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1806358&r1=1806357&r2=1806358&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java Sun Aug 27 12:39:50 2017
@@ -1242,7 +1242,7 @@ public class HTTPHC4Impl extends HTTPHCA
         if(getUseMultipartForPost()) {
             // If a content encoding is specified, we use that as the
             // encoding of any parameter values
-            Charset charset;
+            Charset charset = null;
             if(haveContentEncoding) {
                 charset = Charset.forName(contentEncoding);
             } else {
@@ -1255,6 +1255,9 @@ public class HTTPHC4Impl extends HTTPHCA
             }
             // Write the request to our own stream
             MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
+            if(haveContentEncoding) {
+                multipartEntityBuilder.setCharset(charset);
+            }
             if(getDoBrowserCompatibleMultipart()) {
                 multipartEntityBuilder.setLaxMode();
             } else {
@@ -1268,7 +1271,12 @@ public class HTTPHC4Impl extends HTTPHCA
                 if (arg.isSkippable(parameterName)) {
                     continue;
                 }
-                StringBody stringBody = new StringBody(arg.getValue(), ContentType.create("text/plain", charset));
+                StringBody stringBody;
+                if(haveContentEncoding) {
+                    stringBody = new StringBody(arg.getValue(), ContentType.create("text/plain", charset));
+                } else {
+                    stringBody = new StringBody(arg.getValue(), ContentType.create("text/plain"));
+                }
                 FormBodyPart formPart = FormBodyPartBuilder.create(
                         parameterName, stringBody).build();
                 multipartEntityBuilder.addPart(formPart);