Skip to content
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 @@ -775,6 +775,9 @@ private void consumeFrame(final RawFrame frame) throws HttpException, IOExceptio
if (continuation != null && frameType != FrameType.CONTINUATION) {
throw new H2ConnectionException(H2Error.PROTOCOL_ERROR, "CONTINUATION frame expected");
}
if (frameType == null) {
return;
}
switch (frameType) {
case DATA: {
if (streamId == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,28 @@ void testOutboundTrailersWithPseudoHeaderRejected() throws Exception {

Assertions.assertThrows(H2ConnectionException.class, () -> channel.endStream(trailers));
}

@Test
void testInputUnknownFrameTypeIgnored() throws Exception {
final WritableByteChannelMock writableChannel = new WritableByteChannelMock(1024);
final FrameOutputBuffer outBuffer = new FrameOutputBuffer(16 * 1024);

// 0x0a is not a defined HTTP/2 core frame type in FrameType enum (extension / unknown)
final RawFrame unknownFrame = new RawFrame(0x0a, 0, 0, ByteBuffer.allocate(0));
outBuffer.write(unknownFrame, writableChannel);

final AbstractH2StreamMultiplexer streamMultiplexer = new H2StreamMultiplexerImpl(
protocolIOSession,
FRAME_FACTORY,
StreamIdGenerator.ODD,
httpProcessor,
CharCodingConfig.DEFAULT,
H2Config.custom().build(),
h2StreamListener,
() -> streamHandler);

Assertions.assertDoesNotThrow(() -> streamMultiplexer.onInput(ByteBuffer.wrap(writableChannel.toByteArray())));
}
private static byte[] encodeFrame(final RawFrame frame) throws IOException {
final WritableByteChannelMock writableChannel = new WritableByteChannelMock(256);
final FrameOutputBuffer outBuffer = new FrameOutputBuffer(16 * 1024);
Expand Down
Loading