Skip to content

Commit fd946b8

Browse files
committed
Protected getContentType in DecoderHttpMessageReader
Issue: SPR-16856
1 parent 42b4a2f commit fd946b8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,15 @@ public Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage mes
9393
return this.decoder.decodeToMono(message.getBody(), elementType, contentType, hints);
9494
}
9595

96-
private MediaType getContentType(HttpMessage inputMessage) {
96+
/**
97+
* Determine the Content-Type of the HTTP message based on the
98+
* "Content-Type" header or otherwise default to
99+
* {@link MediaType#APPLICATION_OCTET_STREAM}.
100+
* @param inputMessage the HTTP message
101+
* @return the MediaType, possibly {@code null}.
102+
*/
103+
@Nullable
104+
protected MediaType getContentType(HttpMessage inputMessage) {
97105
MediaType contentType = inputMessage.getHeaders().getContentType();
98106
return (contentType != null ? contentType : MediaType.APPLICATION_OCTET_STREAM);
99107
}

spring-web/src/main/java/org/springframework/web/client/HttpMessageConverterExtractor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ public T extractData(ClientHttpResponse response) throws IOException {
120120
"for response type [" + this.responseType + "] and content type [" + contentType + "]");
121121
}
122122

123+
/**
124+
* Determine the Content-Type of the response based on the "Content-Type"
125+
* header or otherwise default to {@link MediaType#APPLICATION_OCTET_STREAM}.
126+
* @param response the response
127+
* @return the MediaType, possibly {@code null}.
128+
*/
129+
@Nullable
123130
protected MediaType getContentType(ClientHttpResponse response) {
124131
MediaType contentType = response.getHeaders().getContentType();
125132
if (contentType == null) {

0 commit comments

Comments
 (0)