Fixes #4251 - Http 2.0 clients cannot upgrade protocol in 9.4.22 release.

Fixed HTTP2-Settings header parsing.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2019-10-31 15:56:24 +01:00
parent c50c4536dd
commit 4f19e6b638
2 changed files with 9 additions and 4 deletions

View File

@ -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();

View File

@ -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();