diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientTest.java b/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientTest.java index 5702536a53..1300ac9b6a 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/client/HttpClientTest.java @@ -1698,6 +1698,40 @@ void testIssue3538() throws Exception { assertThat(content).isNull(); } + @Test + void testIssue3538GetWithPayload() throws Exception { + disposableServer = + createServer() + .protocol(HttpProtocol.H2C, HttpProtocol.HTTP11) + .route(r -> r.get("/", (req, res) -> { + final EchoAction action = new EchoAction(); + + req + .receiveContent().switchIfEmpty(Mono.just(LastHttpContent.EMPTY_LAST_CONTENT)) + .subscribe(action); + + return res.sendObject(action); + } + )) + .bindNow(); + assertThat(disposableServer).isNotNull(); + + // The H2C max content length is 0 by default (no content is expected), + // so the request is rejected with HTTP/413 Content Too Large + StepVerifier.create(createHttpClientForContextWithPort() + .protocol(HttpProtocol.HTTP11) + .headers(h -> + h.add(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE) + .add(HttpHeaderNames.UPGRADE, "TLS/1.2")) + .request(HttpMethod.GET) + .send((req, res) -> res.sendString(Mono.just("testIssue3538"))) + .uri("/") + .response((r, buf) -> Mono.just(r.status().code()))) + .expectNextMatches(status -> status == 413) + .expectComplete() + .verify(Duration.ofSeconds(30)); + } + @Test void testIssue694() { disposableServer = @@ -3561,6 +3595,9 @@ private static class EchoAction implements Publisher, Consumer 0) { + emitter.next(message.retain()); + } emitter.complete(); } else {