Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP/3 Client handling of MAX_FIELD_SECTION_SIZE setting #10763

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void onSettings(SettingsFrame frame)
else if (key == SettingsFrame.MAX_FIELD_SECTION_SIZE)
{
// Must cap the maxHeaderSize to avoid large allocations.
int maxHeadersSize = (int)Math.min(value, configuration.getMaxResponseHeadersSize());
int maxHeadersSize = (int)Math.min(value, configuration.getMaxRequestHeadersSize());
encoder.setMaxHeadersSize(maxHeadersSize);
}
else if (key == SettingsFrame.MAX_BLOCKED_STREAMS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,22 @@ public Stream.Server.Listener onRequest(Stream.Server stream, HeadersFrame frame
}
});

int maxRequestHeadersSize = 128;
int maxRequestHeadersSize = 256;
HTTP3Configuration http3Configuration = http3Client.getHTTP3Configuration();
http3Configuration.setMaxRequestHeadersSize(maxRequestHeadersSize);
// Disable the dynamic table, otherwise the large header
// is sent as string literal on the encoder stream.
// is sent as string literal on the encoder stream, rather than the message stream.
http3Configuration.setMaxEncoderTableCapacity(0);
Session.Client clientSession = newSession(new Session.Client.Listener() {});
CountDownLatch settingsLatch = new CountDownLatch(1);
Session.Client clientSession = newSession(new Session.Client.Listener()
{
@Override
public void onSettings(Session session, SettingsFrame frame)
{
settingsLatch.countDown();
}
});
assertTrue(settingsLatch.await(5, TimeUnit.SECONDS));

CountDownLatch requestFailureLatch = new CountDownLatch(1);
HttpFields largeHeaders = HttpFields.build().put("too-large", "x".repeat(2 * maxRequestHeadersSize));
Expand Down Expand Up @@ -413,7 +422,7 @@ public void onResponse(Stream.Client stream, HeadersFrame frame)
@Test
public void testResponseHeadersTooLarge() throws Exception
{
int maxResponseHeadersSize = 128;
int maxResponseHeadersSize = 256;
CountDownLatch settingsLatch = new CountDownLatch(2);
AtomicReference<Session> serverSessionRef = new AtomicReference<>();
CountDownLatch responseFailureLatch = new CountDownLatch(1);
Expand Down Expand Up @@ -458,7 +467,7 @@ public Stream.Server.Listener onRequest(Stream.Server stream, HeadersFrame frame
assertNotNull(h3);
HTTP3Configuration http3Configuration = h3.getHTTP3Configuration();
// Disable the dynamic table, otherwise the large header
// is sent as string literal on the encoder stream.
// is sent as string literal on the encoder stream, rather than the message stream.
http3Configuration.setMaxEncoderTableCapacity(0);
http3Configuration.setMaxResponseHeadersSize(maxResponseHeadersSize);

Expand Down