Polishing external contribution

See gh-32622
This commit is contained in:
Arjen Poutsma
2024-04-23 14:23:35 +02:00
parent 3f8a10c19f
commit 6c5ef9715b
2 changed files with 36 additions and 44 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,15 +16,20 @@
package org.springframework.http.codec;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.AbstractEncoder;
import org.springframework.core.codec.Encoder;
import org.springframework.core.codec.Hints;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpLogging;
import org.springframework.http.MediaType;
import org.springframework.http.ReactiveHttpOutputMessage;
@@ -33,11 +38,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.List;
import java.util.Map;
/**
* {@code HttpMessageWriter} that wraps and delegates to an {@link Encoder}.
@@ -127,7 +127,7 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
return body
.singleOrEmpty()
.switchIfEmpty(Mono.defer(() -> {
message.getHeaders().remove(HttpHeaders.CONTENT_TYPE);
message.getHeaders().setContentType(null);
message.getHeaders().setContentLength(0);
return message.setComplete().then(Mono.empty());
}))