You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ab...@apache.org on 2026/02/18 08:37:37 UTC
(httpcomponents-core) branch master updated: Handle unknown HTTP/2 frame types gracefully (#624)
This is an automated email from the ASF dual-hosted git repository.
abernal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
The following commit(s) were added to refs/heads/master by this push:
new d9604f1a3 Handle unknown HTTP/2 frame types gracefully (#624)
d9604f1a3 is described below
commit d9604f1a31a830048bc2f6cd9fedc9ab19d0d35f
Author: Arturo Bernal <ab...@apache.org>
AuthorDate: Wed Feb 18 08:37:33 2026 +0000
Handle unknown HTTP/2 frame types gracefully (#624)
---
.../impl/nio/AbstractH2StreamMultiplexer.java | 3 +++
.../impl/nio/TestAbstractH2StreamMultiplexer.java | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
index c71f2fb02..964ae61e4 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
@@ -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) {
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestAbstractH2StreamMultiplexer.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestAbstractH2StreamMultiplexer.java
index 67427bf2a..65d5493ec 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestAbstractH2StreamMultiplexer.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestAbstractH2StreamMultiplexer.java
@@ -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);