Skip to content

Commit

Permalink
Remove charset from MultipartWriterSupport mediatype
Browse files Browse the repository at this point in the history
This commit drops the 'charset' parameter from the media type set by
MultipartWriterSupport, since RFC7578 states that the only allowed
parameter is 'boundary'.

Closes spring-projectsgh-25885
  • Loading branch information
poutsma committed Nov 17, 2020
1 parent 0819a9f commit 9454021
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ protected MediaType getMultipartMediaType(@Nullable MediaType mediaType, byte[]
params.putAll(mediaType.getParameters());
}
params.put("boundary", new String(boundary, StandardCharsets.US_ASCII));
params.put("charset", getCharset().name());

mediaType = (mediaType != null ? mediaType : MediaType.MULTIPART_FORM_DATA);
mediaType = new MediaType(mediaType, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void writeMultipartRelated() {
assertThat(contentType.isCompatibleWith(mediaType)).isTrue();
assertThat(contentType.getParameter("type")).isEqualTo("foo");
assertThat(contentType.getParameter("boundary")).isNotEmpty();
assertThat(contentType.getParameter("charset")).isEqualTo("UTF-8");
assertThat(contentType.getParameter("charset")).isNull();

MultiValueMap<String, Part> requestParts = parse(this.response, hints);
assertThat(requestParts.size()).isEqualTo(2);
Expand Down

0 comments on commit 9454021

Please sign in to comment.