#10759 fix client setting MAX_FIELD_SECTION_SIZE to check its max value against H3 config setting maxRequestHeadersSize

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2023-10-20 15:30:02 +02:00
parent 33e35df544
commit 59105bef4d
2 changed files with 15 additions and 6 deletions

View File

@ -184,7 +184,7 @@ public class ClientHTTP3Session extends ClientProtocolSession
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)

View File

@ -373,13 +373,22 @@ public class ClientServerTest extends AbstractClientServerTest
}
});
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));
@ -413,7 +422,7 @@ public class ClientServerTest extends AbstractClientServerTest
@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);
@ -458,7 +467,7 @@ public class ClientServerTest extends AbstractClientServerTest
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);