diff --git a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java index 50e9a264d1a..d94104535d1 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java @@ -16,7 +16,6 @@ package org.springframework.http.codec.multipart; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -146,17 +145,6 @@ public class MultipartHttpMessageWriter extends MultipartWriterSupport return this.formWriter; } - /** - * Set the character set to use for part headers such as - * "Content-Disposition" (and its filename parameter). - *

By default this is set to "UTF-8". If changed from this default, - * the "Content-Type" header will have a "charset" parameter that specifies - * the character set used. - */ - public void setCharset(Charset charset) { - Assert.notNull(charset, "Charset must not be null"); - this.charset = charset; - } @Override diff --git a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartWriterSupport.java b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartWriterSupport.java index 0ddae070e04..b07eb720a56 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartWriterSupport.java +++ b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartWriterSupport.java @@ -30,6 +30,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.codec.LoggingCodecSupport; import org.springframework.lang.Nullable; +import org.springframework.util.Assert; import org.springframework.util.MimeTypeUtils; import org.springframework.util.MultiValueMap; @@ -44,9 +45,9 @@ public class MultipartWriterSupport extends LoggingCodecSupport { /** THe default charset used by the writer. */ public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; - protected final List supportedMediaTypes; + private final List supportedMediaTypes; - protected Charset charset = DEFAULT_CHARSET; + private Charset charset = DEFAULT_CHARSET; /** @@ -64,6 +65,18 @@ public class MultipartWriterSupport extends LoggingCodecSupport { return this.charset; } + /** + * Set the character set to use for part headers such as + * "Content-Disposition" (and its filename parameter). + *

By default this is set to "UTF-8". If changed from this default, + * the "Content-Type" header will have a "charset" parameter that specifies + * the character set used. + */ + public void setCharset(Charset charset) { + Assert.notNull(charset, "Charset must not be null"); + this.charset = charset; + } + public List getWritableMediaTypes() { return this.supportedMediaTypes; }