Skip to content

Commit 9cc710f

Browse files
markt-asfCopilot
andcommitted
Add HTTP/2 from CoPilot review of 0de12dcc
Add test for HTTP/2 HEADERS frame with both PADDED and PRIORITY flags too much padding Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 92cd004 commit 9cc710f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/org/apache/coyote/http2/TestHttp2Section_6_2.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,42 @@ public void testHeaderFrameTooMuchPadding() throws Exception {
9191
}
9292

9393

94+
@Test
95+
public void testHeaderFrameTooMuchPaddingWithPriority() throws Exception {
96+
// Tests the case where both PADDED and PRIORITY flags are set and the
97+
// padding length is too large relative to the payload after accounting
98+
// for the optional bytes (1 byte pad length + 5 bytes priority = 6 bytes).
99+
// With payloadSize=8 and padLength=3, the actual available payload
100+
// after optional bytes is only 2, so padLength >= available triggers
101+
// a PROTOCOL_ERROR and a GOAWAY frame must be sent.
102+
http2Connect();
103+
104+
// 9 bytes frame header + 8 bytes payload
105+
byte[] headerFrame = new byte[17];
106+
107+
// Header
108+
// length = 8
109+
ByteUtil.setThreeBytes(headerFrame, 0, 8);
110+
headerFrame[3] = FrameType.HEADERS.getIdByte();
111+
// flags: PADDED (0x08) | PRIORITY (0x20)
112+
headerFrame[4] = 0x28;
113+
// stream 3
114+
ByteUtil.set31Bits(headerFrame, 5, 3);
115+
// payload:
116+
// pad length = 3 (too large: only 2 bytes remain after 6 optional bytes)
117+
headerFrame[9] = 3;
118+
// priority: 5 bytes (bytes 10-14, all zero)
119+
// remaining 2 bytes: bytes 15-16 (all zero)
120+
121+
os.write(headerFrame);
122+
os.flush();
123+
124+
// 1 is the last stream processed before the connection error (stream 1
125+
// from the initial HTTP/1.1 upgrade)
126+
handleGoAwayResponse(1);
127+
}
128+
129+
94130
@Test
95131
public void testHeaderFrameWithZeroLengthPadding() throws Exception {
96132
http2Connect();

0 commit comments

Comments
 (0)