Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The HTTP Header of multipart/form-data no longer includes charset. #6251

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,6 @@ protected String setupHttpEntityEnclosingRequestData(HttpEntityEnclosingRequestB
}
// Write the request to our own stream
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
multipartEntityBuilder.setCharset(charset);
if (doBrowserCompatibleMultipart) {
multipartEntityBuilder.setLaxMode();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ void testFileargWithMimeTypeWithCharset() throws Exception {
Assertions.assertTrue(requestData.contains("charset=utf-8"));
}

@Test
void testMultipartFormHeaderWithoutCharset() throws Exception {
HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
sampler.setThreadContext(jmctx);
sampler.setDoMultipart(true);
sampler.setDoBrowserCompatibleMultipart(true);
HttpEntityEnclosingRequestBase post = new HttpPost();
post.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, "application/json; charset=utf-8");
sampler.setHTTPFiles(new HTTPFileArg[] {new HTTPFileArg("filename", "file", "application/octect; charset=utf-8")});
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
String requestData = hc.setupHttpEntityEnclosingRequestData(post);

String contentTypeWithEntity = post.getEntity().getContentType().getValue();
Assertions.assertFalse(contentTypeWithEntity.contains("charset"));
}

@Test
public void testNotifyFirstSampleAfterLoopRestartWhenThreadIterationIsSameUser() {
jmvars.putObject(SAME_USER, true);
Expand Down
Loading