Skip to content

Commit

Permalink
Add test case for HTTP/1.1 TLS Upgrade (RFC-2817) with body
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Dec 11, 2024
1 parent cda3662 commit 298725c
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -3561,6 +3595,9 @@ private static class EchoAction implements Publisher<HttpContent>, Consumer<Http
@Override
public void accept(HttpContent message) {
if (message instanceof LastHttpContent) {
if (message.content().readableBytes() > 0) {
emitter.next(message.retain());
}
emitter.complete();
}
else {
Expand Down

0 comments on commit 298725c

Please sign in to comment.