Add ClientResponse::releaseBody

See gh-23498
This commit is contained in:
Arjen Poutsma
2019-08-30 11:23:40 +02:00
parent bc869657c8
commit f5640cbfe0
4 changed files with 56 additions and 5 deletions

View File

@@ -166,6 +166,25 @@ public class WebClientDataBufferAllocatingTests extends AbstractDataBufferAlloca
});
}
@ParameterizedDataBufferAllocatingTest
public void releaseBody(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
this.server.enqueue(new MockResponse()
.setResponseCode(200)
.setHeader("Content-Type", "text/plain")
.setBody("foo bar"));
Mono<Void> result = this.webClient.get()
.exchange()
.flatMap(ClientResponse::releaseBody);
StepVerifier.create(result)
.expectComplete()
.verify(Duration.ofSeconds(3));
}
private void testOnStatus(Throwable expected,
Function<ClientResponse, Mono<? extends Throwable>> exceptionFunction) {