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:
parent
c50c4536dd
commit
4f19e6b638
|
@ -83,6 +83,11 @@ public class SettingsBodyParser extends BodyParser
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean parse(ByteBuffer buffer)
|
public boolean parse(ByteBuffer buffer)
|
||||||
|
{
|
||||||
|
return parse(buffer, getStreamId(), getBodyLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean parse(ByteBuffer buffer, int streamId, int bodyLength)
|
||||||
{
|
{
|
||||||
while (buffer.hasRemaining())
|
while (buffer.hasRemaining())
|
||||||
{
|
{
|
||||||
|
@ -91,9 +96,9 @@ public class SettingsBodyParser extends BodyParser
|
||||||
case PREPARE:
|
case PREPARE:
|
||||||
{
|
{
|
||||||
// SPEC: wrong streamId is treated as connection error.
|
// SPEC: wrong streamId is treated as connection error.
|
||||||
if (getStreamId() != 0)
|
if (streamId != 0)
|
||||||
return connectionFailure(buffer, ErrorCode.PROTOCOL_ERROR.code, "invalid_settings_frame");
|
return connectionFailure(buffer, ErrorCode.PROTOCOL_ERROR.code, "invalid_settings_frame");
|
||||||
length = getBodyLength();
|
length = bodyLength;
|
||||||
settings = new HashMap<>();
|
settings = new HashMap<>();
|
||||||
state = State.SETTING_ID;
|
state = State.SETTING_ID;
|
||||||
break;
|
break;
|
||||||
|
@ -234,7 +239,7 @@ public class SettingsBodyParser extends BodyParser
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (buffer.hasRemaining())
|
if (buffer.hasRemaining())
|
||||||
parser.parse(buffer);
|
parser.parse(buffer, 0, buffer.remaining());
|
||||||
else
|
else
|
||||||
parser.emptyBody(buffer);
|
parser.emptyBody(buffer);
|
||||||
return frameRef.get();
|
return frameRef.get();
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class HTTP2CServerTest extends AbstractServerTest
|
||||||
"Host: localhost\r\n" +
|
"Host: localhost\r\n" +
|
||||||
"Connection: something, else, upgrade, HTTP2-Settings\r\n" +
|
"Connection: something, else, upgrade, HTTP2-Settings\r\n" +
|
||||||
"Upgrade: h2c\r\n" +
|
"Upgrade: h2c\r\n" +
|
||||||
"HTTP2-Settings: \r\n" +
|
"HTTP2-Settings: AAEAAEAAAAIAAAABAAMAAABkAAQBAAAAAAUAAEAA\r\n" +
|
||||||
"\r\n").getBytes(StandardCharsets.ISO_8859_1));
|
"\r\n").getBytes(StandardCharsets.ISO_8859_1));
|
||||||
output.flush();
|
output.flush();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue