Rename MimeType's getCharSet() to getCharset()
Issue: SPR-14172
This commit is contained in:
@@ -246,7 +246,7 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
|
||||
contentTypeToUse = (mediaType != null ? mediaType : contentTypeToUse);
|
||||
}
|
||||
if (contentTypeToUse != null) {
|
||||
if (contentTypeToUse.getCharSet() == null && this.defaultCharset != null) {
|
||||
if (contentTypeToUse.getCharset() == null && this.defaultCharset != null) {
|
||||
contentTypeToUse = new MediaType(contentTypeToUse, this.defaultCharset);
|
||||
}
|
||||
headers.setContentType(contentTypeToUse);
|
||||
|
||||
@@ -202,7 +202,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
|
||||
|
||||
MediaType contentType = inputMessage.getHeaders().getContentType();
|
||||
Charset charset = (contentType.getCharSet() != null ? contentType.getCharSet() : this.charset);
|
||||
Charset charset = (contentType.getCharset() != null ? contentType.getCharset() : this.charset);
|
||||
String body = StreamUtils.copyToString(inputMessage.getBody(), charset);
|
||||
|
||||
String[] pairs = StringUtils.tokenizeToStringArray(body, "&");
|
||||
@@ -255,7 +255,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
Charset charset;
|
||||
if (contentType != null) {
|
||||
outputMessage.getHeaders().setContentType(contentType);
|
||||
charset = contentType.getCharSet() != null ? contentType.getCharSet() : this.charset;
|
||||
charset = contentType.getCharset() != null ? contentType.getCharset() : this.charset;
|
||||
}
|
||||
else {
|
||||
outputMessage.getHeaders().setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
|
||||
@@ -118,8 +118,8 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
|
||||
}
|
||||
|
||||
private Charset getContentTypeCharset(MediaType contentType) {
|
||||
if (contentType != null && contentType.getCharSet() != null) {
|
||||
return contentType.getCharSet();
|
||||
if (contentType != null && contentType.getCharset() != null) {
|
||||
return contentType.getCharset();
|
||||
}
|
||||
else {
|
||||
return this.getDefaultCharset();
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class AbstractWireFeedHttpMessageConverter<T extends WireFeed> e
|
||||
WireFeedInput feedInput = new WireFeedInput();
|
||||
MediaType contentType = inputMessage.getHeaders().getContentType();
|
||||
Charset charset =
|
||||
(contentType != null && contentType.getCharSet() != null? contentType.getCharSet() : DEFAULT_CHARSET);
|
||||
(contentType != null && contentType.getCharset() != null? contentType.getCharset() : DEFAULT_CHARSET);
|
||||
try {
|
||||
Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
|
||||
return (T) feedInput.build(reader);
|
||||
|
||||
@@ -348,8 +348,8 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
||||
* @return the JSON encoding to use (never {@code null})
|
||||
*/
|
||||
protected JsonEncoding getJsonEncoding(MediaType contentType) {
|
||||
if (contentType != null && contentType.getCharSet() != null) {
|
||||
Charset charset = contentType.getCharSet();
|
||||
if (contentType != null && contentType.getCharset() != null) {
|
||||
Charset charset = contentType.getCharset();
|
||||
for (JsonEncoding encoding : JsonEncoding.values()) {
|
||||
if (charset.name().equals(encoding.getJavaName())) {
|
||||
return encoding;
|
||||
|
||||
@@ -178,10 +178,10 @@ public class GsonHttpMessageConverter extends AbstractGenericHttpMessageConverte
|
||||
}
|
||||
|
||||
private Charset getCharset(HttpHeaders headers) {
|
||||
if (headers == null || headers.getContentType() == null || headers.getContentType().getCharSet() == null) {
|
||||
if (headers == null || headers.getContentType() == null || headers.getContentType().getCharset() == null) {
|
||||
return DEFAULT_CHARSET;
|
||||
}
|
||||
return headers.getContentType().getCharSet();
|
||||
return headers.getContentType().getCharset();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M
|
||||
if (contentType == null) {
|
||||
contentType = PROTOBUF;
|
||||
}
|
||||
Charset charset = contentType.getCharSet();
|
||||
Charset charset = contentType.getCharset();
|
||||
if (charset == null) {
|
||||
charset = DEFAULT_CHARSET;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M
|
||||
if (contentType == null) {
|
||||
contentType = getDefaultContentType(message);
|
||||
}
|
||||
Charset charset = contentType.getCharSet();
|
||||
Charset charset = contentType.getCharset();
|
||||
if (charset == null) {
|
||||
charset = DEFAULT_CHARSET;
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ public class Jaxb2RootElementHttpMessageConverter extends AbstractJaxb2HttpMessa
|
||||
}
|
||||
|
||||
private void setCharset(MediaType contentType, Marshaller marshaller) throws PropertyException {
|
||||
if (contentType != null && contentType.getCharSet() != null) {
|
||||
marshaller.setProperty(Marshaller.JAXB_ENCODING, contentType.getCharSet().name());
|
||||
if (contentType != null && contentType.getCharset() != null) {
|
||||
marshaller.setProperty(Marshaller.JAXB_ENCODING, contentType.getCharset().name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
this.headers.setContentType(contentType);
|
||||
}
|
||||
}
|
||||
if (contentType != null && contentType.getCharSet() == null) {
|
||||
if (contentType != null && contentType.getCharset() == null) {
|
||||
String requestEncoding = this.servletRequest.getCharacterEncoding();
|
||||
if (StringUtils.hasLength(requestEncoding)) {
|
||||
Charset charSet = Charset.forName(requestEncoding);
|
||||
|
||||
@@ -114,8 +114,8 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
|
||||
this.servletResponse.setContentType(this.headers.getContentType().toString());
|
||||
}
|
||||
if (this.servletResponse.getCharacterEncoding() == null && this.headers.getContentType() != null &&
|
||||
this.headers.getContentType().getCharSet() != null) {
|
||||
this.servletResponse.setCharacterEncoding(this.headers.getContentType().getCharSet().name());
|
||||
this.headers.getContentType().getCharset() != null) {
|
||||
this.servletResponse.setCharacterEncoding(this.headers.getContentType().getCharset().name());
|
||||
}
|
||||
this.headersWritten = true;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
|
||||
private Charset getCharset(ClientHttpResponse response) {
|
||||
HttpHeaders headers = response.getHeaders();
|
||||
MediaType contentType = headers.getContentType();
|
||||
return contentType != null ? contentType.getCharSet() : null;
|
||||
return contentType != null ? contentType.getCharset() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
List<MediaType> supportedMediaTypes = messageConverter.getSupportedMediaTypes();
|
||||
List<MediaType> result = new ArrayList<MediaType>(supportedMediaTypes.size());
|
||||
for (MediaType supportedMediaType : supportedMediaTypes) {
|
||||
if (supportedMediaType.getCharSet() != null) {
|
||||
if (supportedMediaType.getCharset() != null) {
|
||||
supportedMediaType =
|
||||
new MediaType(supportedMediaType.getType(), supportedMediaType.getSubtype());
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ public abstract class CommonsFileUploadSupport {
|
||||
return defaultEncoding;
|
||||
}
|
||||
MediaType contentType = MediaType.parseMediaType(contentTypeHeader);
|
||||
Charset charset = contentType.getCharSet();
|
||||
Charset charset = contentType.getCharset();
|
||||
return (charset != null ? charset.name() : defaultEncoding);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class RequestPartServletServerHttpRequest extends ServletServerHttpReques
|
||||
private String determineEncoding() {
|
||||
MediaType contentType = getHeaders().getContentType();
|
||||
if (contentType != null) {
|
||||
Charset charset = contentType.getCharSet();
|
||||
Charset charset = contentType.getCharset();
|
||||
if (charset != null) {
|
||||
return charset.name();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user