Skip to content

Commit 617b94a

Browse files
committed
Polish
See SPR-17502
1 parent 5342c6e commit 617b94a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,12 @@ public Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType eleme
105105

106106
if (inputStream instanceof Mono) {
107107
HttpHeaders headers = message.getHeaders();
108-
if (!headers.containsKey(HttpHeaders.TRANSFER_ENCODING)) {
109-
return Mono.from(body)
110-
.defaultIfEmpty(message.bufferFactory().wrap(new byte[0]))
111-
.flatMap(buffer -> {
112-
headers.setContentLength(buffer.readableByteCount());
113-
return message.writeWith(Mono.just(buffer));
114-
});
115-
}
108+
return Mono.from(body)
109+
.defaultIfEmpty(message.bufferFactory().wrap(new byte[0]))
110+
.flatMap(buffer -> {
111+
headers.setContentLength(buffer.readableByteCount());
112+
return message.writeWith(Mono.just(buffer));
113+
});
116114
}
117115

118116
return (isStreamingMediaType(contentType) ?

0 commit comments

Comments
 (0)