GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge commit from fork · netty/netty@541add0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-http2/src
    • main/java/io/netty/handler/codec/http2
      • DefaultHttp2ConnectionEncoder.java
    • test/java/io/netty/handler/codec/http2
      • Http2ConnectionRoundtripTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java‎

Copy file name to clipboardExpand all lines: codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public void remoteSettings(Http2Settings settings) throws Http2Exception {
100100
}
101101

102102
Long maxHeaderListSize = settings.maxHeaderListSize();
103-
if (maxHeaderListSize != null) {
103+
if (maxHeaderListSize != null && !connection.isServer()) {
104+
// Servers ignore the MAX_HEADER_LIST_SIZE setting from clients.
105+
// It's advisory in spec (RFC 9113 §6.5.2) and best praxis is to ignore it.
104106
outboundHeaderConfig.maxHeaderListSize(maxHeaderListSize);
105107
}
106108

Collapse file

‎codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java‎

Copy file name to clipboardExpand all lines: codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java
+65Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,71 @@ public void run() throws Http2Exception {
11421142
}
11431143
}
11441144

1145+
@Test
1146+
public void serverShouldNotEnforceClientAdvertisedMaxHeaderListSize() throws Exception {
1147+
// Verifies that SETTINGS_MAX_HEADER_LIST_SIZE sent by a client is treated as advisory
1148+
// (per RFC 9113 §6.5.2) and does not prevent the server from encoding response headers.
1149+
final CountDownLatch clientSettingsAckLatch = new CountDownLatch(2);
1150+
final CountDownLatch responseLatch = new CountDownLatch(1);
1151+
final AtomicReference<Throwable> serverWriteError = new AtomicReference<Throwable>();
1152+
1153+
doAnswer(new Answer<Void>() {
1154+
@Override
1155+
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
1156+
final ChannelHandlerContext sCtx = serverCtx();
1157+
final int streamId = (Integer) invocationOnMock.getArgument(1);
1158+
Http2Headers responseHeaders = new DefaultHttp2Headers().status("200");
1159+
http2Server.encoder().writeHeaders(sCtx, streamId, responseHeaders, 0, true, sCtx.newPromise())
1160+
.addListener(future -> {
1161+
serverWriteError.set(future.cause());
1162+
responseLatch.countDown();
1163+
});
1164+
http2Server.flush(sCtx);
1165+
return null;
1166+
}
1167+
}).when(serverListener).onHeadersRead(any(ChannelHandlerContext.class), anyInt(), any(Http2Headers.class),
1168+
anyInt(), anyShort(), anyBoolean(), anyInt(), anyBoolean());
1169+
1170+
doAnswer(new Answer<Void>() {
1171+
@Override
1172+
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
1173+
clientSettingsAckLatch.countDown();
1174+
return null;
1175+
}
1176+
}).when(clientListener).onSettingsAckRead(any(ChannelHandlerContext.class));
1177+
1178+
bootstrapEnv(0, 1, 2, 0);
1179+
1180+
// Client advertises a tiny MAX_HEADER_LIST_SIZE (2 bytes) to the server.
1181+
runInChannel(clientChannel, new Http2Runnable() {
1182+
@Override
1183+
public void run() throws Http2Exception {
1184+
http2Client.encoder().writeSettings(ctx(),
1185+
new Http2Settings().maxHeaderListSize(2),
1186+
newPromise());
1187+
http2Client.flush(ctx());
1188+
}
1189+
});
1190+
1191+
// Wait for the server to acknowledge both the initial settings and our custom settings.
1192+
assertTrue(clientSettingsAckLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS));
1193+
1194+
// Send a request; the server will attempt to respond with headers far exceeding 2 bytes.
1195+
final short weight = 16;
1196+
runInChannel(clientChannel, new Http2Runnable() {
1197+
@Override
1198+
public void run() throws Http2Exception {
1199+
http2Client.encoder().writeHeaders(ctx(), 3, dummyHeaders(), 0, weight, false, 0, true,
1200+
newPromise());
1201+
http2Client.flush(ctx());
1202+
}
1203+
});
1204+
1205+
assertTrue(responseLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS));
1206+
assertNull(serverWriteError.get(),
1207+
"Server must succeed writing response headers regardless of client's SETTINGS_MAX_HEADER_LIST_SIZE");
1208+
}
1209+
11451210
private void bootstrapEnv(int dataCountDown, int settingsAckCount,
11461211
int requestCountDown, int trailersCountDown) throws Exception {
11471212
bootstrapEnv(dataCountDown, settingsAckCount, requestCountDown, trailersCountDown, -1, -1);

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.