Skip to content

Commit

Permalink
When the server upgrades an HTTP/1.1 connection to H2C, it forwards i…
Browse files Browse the repository at this point in the history
…nbound HTTP messages to the H2 encoder and updates the frame controller with the received amount of bytes. Actually such messages are not taken in account by the H2 flow controller and therefore when the window size becomes zero, it will not process message anymore.

This impacts HTTP/1.1 upgrades to H2C sending messages payload greater than the flow control window size.

The VertxHttp2ConnectionHandler has been updated to not account for received HTTP/1.1 bytes.
  • Loading branch information
vietj committed Aug 8, 2023
1 parent 9770518 commit 322d095
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,6 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
connection.onHeadersRead(ctx, 1, frame.headers(), frame.padding(), frame.isEndStream());
} else if (msg instanceof Http2DataFrame) {
Http2DataFrame frame = (Http2DataFrame) msg;
Http2LocalFlowController controller = decoder().flowController();
Http2Stream stream = decoder().connection().stream(1);
controller.receiveFlowControlledFrame(stream, frame.content(), frame.padding(), frame.isEndStream());
connection.onDataRead(ctx, 1, frame.content(), frame.padding(), frame.isEndStream());
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.core.http;

/**
*/
public class Http2WithUpgradeServerFileUploadTest extends HttpServerFileUploadTest {

@Override
protected HttpClientOptions createBaseClientOptions() {
return new HttpClientOptions()
.setProtocolVersion(HttpVersion.HTTP_2)
.setHttp2ClearTextUpgrade(true);
}

}
16 changes: 6 additions & 10 deletions src/test/java/io/vertx/core/http/HttpServerFileUploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,12 @@ private void testFormUploadFile(String filename,
"\r\n";
req.headers().set("content-length", "" + (pro + contentStr + epi).length());
req.headers().set("content-type", "multipart/form-data; boundary=" + boundary);
if (abortClient || cancelStream) {
Future<Void> fut = req.write(pro + contentStr.substring(0, contentStr.length() / 2));
if (abortClient) {
fut.onComplete(onSuccess(v -> {
clientConn.set(req.connection());
checkClose.run();
}));
}
} else {
req.end(pro + contentStr + epi);
Future<Void> fut = req.end(pro + contentStr + epi);
if (abortClient) {
fut.onComplete(onSuccess(v -> {
clientConn.set(req.connection());
checkClose.run();
}));
}
if (abortClient) {
req.response(onFailure(err -> complete()));
Expand Down

0 comments on commit 322d095

Please sign in to comment.