diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/SettingsBodyParser.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/SettingsBodyParser.java index b58fa8a8b51..5ca509f1271 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/SettingsBodyParser.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/SettingsBodyParser.java @@ -83,6 +83,11 @@ public class SettingsBodyParser extends BodyParser @Override public boolean parse(ByteBuffer buffer) + { + return parse(buffer, getStreamId(), getBodyLength()); + } + + private boolean parse(ByteBuffer buffer, int streamId, int bodyLength) { while (buffer.hasRemaining()) { @@ -91,9 +96,9 @@ public class SettingsBodyParser extends BodyParser case PREPARE: { // SPEC: wrong streamId is treated as connection error. - if (getStreamId() != 0) + if (streamId != 0) return connectionFailure(buffer, ErrorCode.PROTOCOL_ERROR.code, "invalid_settings_frame"); - length = getBodyLength(); + length = bodyLength; settings = new HashMap<>(); state = State.SETTING_ID; break; @@ -234,7 +239,7 @@ public class SettingsBodyParser extends BodyParser } }); if (buffer.hasRemaining()) - parser.parse(buffer); + parser.parse(buffer, 0, buffer.remaining()); else parser.emptyBody(buffer); return frameRef.get(); diff --git a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2CServerTest.java b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2CServerTest.java index 48552abebac..0dbfd503e0d 100644 --- a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2CServerTest.java +++ b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2CServerTest.java @@ -125,7 +125,7 @@ public class HTTP2CServerTest extends AbstractServerTest "Host: localhost\r\n" + "Connection: something, else, upgrade, HTTP2-Settings\r\n" + "Upgrade: h2c\r\n" + - "HTTP2-Settings: \r\n" + + "HTTP2-Settings: AAEAAEAAAAIAAAABAAMAAABkAAQBAAAAAAUAAEAA\r\n" + "\r\n").getBytes(StandardCharsets.ISO_8859_1)); output.flush();