Use singleOrEmpty to avoid upstream cancel

Closes gh-22952
This commit is contained in:
Rossen Stoyanchev
2019-05-15 16:02:28 -04:00
parent d3110c452e
commit 0274752fe9
2 changed files with 14 additions and 6 deletions

View File

@@ -120,7 +120,8 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
if (inputStream instanceof Mono) {
HttpHeaders headers = message.getHeaders();
return Mono.from(body)
return body
.singleOrEmpty()
.switchIfEmpty(Mono.defer(() -> {
headers.setContentLength(0);
return message.setComplete().then(Mono.empty());