提交 d709a69f 编写于 作者: A Arjen Poutsma

Remove buffering of encoded parts in MultipartHttpMessageWriter

Closes gh-23518
上级 2c5958e1
......@@ -27,7 +27,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
......@@ -249,8 +248,8 @@ public class MultipartHttpMessageWriter extends LoggingCodecSupport
private Flux<DataBuffer> encodePartValues(
byte[] boundary, String name, List<?> values, DataBufferFactory bufferFactory) {
return Flux.concat(values.stream().map(v ->
encodePart(boundary, name, v, bufferFactory)).collect(Collectors.toList()));
return Flux.fromIterable(values)
.concatMap(value -> encodePart(boundary, name, value, bufferFactory));
}
@SuppressWarnings("unchecked")
......
......@@ -409,12 +409,13 @@ public class WebClientIntegrationTests {
byte[] expected = Files.readAllBytes(resource.getFile().toPath());
Flux<DataBuffer> body = DataBufferUtils.read(resource, new DefaultDataBufferFactory(), 4096);
this.webClient.post()
Mono<Void> result = this.webClient.post()
.uri("/")
.body(body, DataBuffer.class)
.retrieve()
.bodyToMono(Void.class)
.block(Duration.ofSeconds(5));
.bodyToMono(Void.class);
StepVerifier.create(result).verifyComplete();
expectRequest(request -> {
ByteArrayOutputStream actual = new ByteArrayOutputStream();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册