|
|
|
@ -60,8 +60,8 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean canWrite(ResolvableType type, MediaType mediaType, Map<String, Object> hints) { |
|
|
|
public boolean canWrite(ResolvableType elementType, MediaType mediaType, Map<String, Object> hints) { |
|
|
|
return this.encoder != null && this.encoder.canEncode(type, mediaType, hints); |
|
|
|
return this.encoder != null && this.encoder.canEncode(elementType, mediaType, hints); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -71,8 +71,8 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType type, |
|
|
|
public Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType elementType, |
|
|
|
MediaType contentType, ReactiveHttpOutputMessage outputMessage, |
|
|
|
MediaType mediaType, ReactiveHttpOutputMessage outputMessage, |
|
|
|
Map<String, Object> hints) { |
|
|
|
Map<String, Object> hints) { |
|
|
|
|
|
|
|
|
|
|
|
if (this.encoder == null) { |
|
|
|
if (this.encoder == null) { |
|
|
|
@ -81,19 +81,19 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> { |
|
|
|
|
|
|
|
|
|
|
|
HttpHeaders headers = outputMessage.getHeaders(); |
|
|
|
HttpHeaders headers = outputMessage.getHeaders(); |
|
|
|
if (headers.getContentType() == null) { |
|
|
|
if (headers.getContentType() == null) { |
|
|
|
MediaType contentTypeToUse = contentType; |
|
|
|
MediaType contentTypeToUse = mediaType; |
|
|
|
if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) { |
|
|
|
if (mediaType == null || mediaType.isWildcardType() || mediaType.isWildcardSubtype()) { |
|
|
|
contentTypeToUse = getDefaultContentType(type); |
|
|
|
contentTypeToUse = getDefaultContentType(elementType); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (MediaType.APPLICATION_OCTET_STREAM.equals(contentType)) { |
|
|
|
else if (MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) { |
|
|
|
MediaType mediaType = getDefaultContentType(type); |
|
|
|
MediaType contentType = getDefaultContentType(elementType); |
|
|
|
contentTypeToUse = (mediaType != null ? mediaType : contentTypeToUse); |
|
|
|
contentTypeToUse = (contentType != null ? contentType : contentTypeToUse); |
|
|
|
} |
|
|
|
} |
|
|
|
if (contentTypeToUse != null) { |
|
|
|
if (contentTypeToUse != null) { |
|
|
|
if (contentTypeToUse.getCharset() == null) { |
|
|
|
if (contentTypeToUse.getCharset() == null) { |
|
|
|
MediaType mediaType = getDefaultContentType(type); |
|
|
|
MediaType contentType = getDefaultContentType(elementType); |
|
|
|
if (mediaType != null && mediaType.getCharset() != null) { |
|
|
|
if (contentType != null && contentType.getCharset() != null) { |
|
|
|
contentTypeToUse = new MediaType(contentTypeToUse, mediaType.getCharset()); |
|
|
|
contentTypeToUse = new MediaType(contentTypeToUse, contentType.getCharset()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
headers.setContentType(contentTypeToUse); |
|
|
|
headers.setContentType(contentTypeToUse); |
|
|
|
@ -101,7 +101,7 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DataBufferFactory bufferFactory = outputMessage.bufferFactory(); |
|
|
|
DataBufferFactory bufferFactory = outputMessage.bufferFactory(); |
|
|
|
Flux<DataBuffer> body = this.encoder.encode(inputStream, bufferFactory, type, contentType, hints); |
|
|
|
Flux<DataBuffer> body = this.encoder.encode(inputStream, bufferFactory, elementType, mediaType, hints); |
|
|
|
return outputMessage.writeWith(body); |
|
|
|
return outputMessage.writeWith(body); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|