Commit 74945024 authored by Victor Vasiliev's avatar Victor Vasiliev Committed by Commit Bot

Reformat char literals in HTTP2 to use '\xNN' format.

This way, there won't be a signedness issue when compared to the
internal codebase.

Merge internal change: 222066172

R=bnc@chromium.org

Change-Id: I5c528d96fa459b039582ba3852a16da158db1f70
Reviewed-on: https://chromium-review.googlesource.com/c/1341653Reviewed-by: default avatarBence Béky <bnc@chromium.org>
Commit-Queue: Victor Vasiliev <vasilvv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609321}
parent 43566aa1
...@@ -105,12 +105,12 @@ TEST_F(FrameHeaderDecoderTest, DecodesLiteral) { ...@@ -105,12 +105,12 @@ TEST_F(FrameHeaderDecoderTest, DecodesLiteral) {
{ {
// Realistic input. // Realistic input.
const char kData[] = { const char kData[] = {
0x00, 0x00, 0x05, // Payload length: 5 '\x00', '\x00', '\x05', // Payload length: 5
0x01, // Frame type: HEADERS '\x01', // Frame type: HEADERS
0x08, // Flags: PADDED '\x08', // Flags: PADDED
0x00, 0x00, 0x00, 0x01, // Stream ID: 1 '\x00', '\x00', '\x00', '\x01', // Stream ID: 1
0x04, // Padding length: 4 '\x04', // Padding length: 4
0x00, 0x00, 0x00, 0x00, // Padding bytes '\x00', '\x00', '\x00', '\x00', // Padding bytes
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -123,10 +123,10 @@ TEST_F(FrameHeaderDecoderTest, DecodesLiteral) { ...@@ -123,10 +123,10 @@ TEST_F(FrameHeaderDecoderTest, DecodesLiteral) {
{ {
// Unlikely input. // Unlikely input.
const char kData[] = { const char kData[] = {
0xffu, 0xffu, 0xffu, // Payload length: uint24 max '\xff', '\xff', '\xff', // Payload length: uint24 max
0xffu, // Frame type: Unknown '\xff', // Frame type: Unknown
0xffu, // Flags: Unknown/All '\xff', // Flags: Unknown/All
0xffu, 0xffu, 0xffu, 0xffu, // Stream ID: uint31 max, plus R-bit '\xff', '\xff', '\xff', '\xff', // Stream ID: uint31 max, plus R-bit
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -150,8 +150,8 @@ class PriorityFieldsDecoderTest ...@@ -150,8 +150,8 @@ class PriorityFieldsDecoderTest
TEST_F(PriorityFieldsDecoderTest, DecodesLiteral) { TEST_F(PriorityFieldsDecoderTest, DecodesLiteral) {
{ {
const char kData[] = { const char kData[] = {
0x80u, 0x00, 0x00, 0x05, // Exclusive (yes) and Dependency (5) '\x80', '\x00', '\x00', '\x05', // Exclusive (yes) and Dependency (5)
0xffu, // Weight: 256 (after adding 1) '\xff', // Weight: 256 (after adding 1)
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -162,9 +162,9 @@ TEST_F(PriorityFieldsDecoderTest, DecodesLiteral) { ...@@ -162,9 +162,9 @@ TEST_F(PriorityFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0x7f, 0xffu, '\x7f', '\xff',
0xffu, 0xffu, // Exclusive (no) and Dependency (0x7fffffff) '\xff', '\xff', // Exclusive (no) and Dependency (0x7fffffff)
0x00, // Weight: 1 (after adding 1) '\x00', // Weight: 1 (after adding 1)
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -187,7 +187,7 @@ class RstStreamFieldsDecoderTest ...@@ -187,7 +187,7 @@ class RstStreamFieldsDecoderTest
TEST_F(RstStreamFieldsDecoderTest, DecodesLiteral) { TEST_F(RstStreamFieldsDecoderTest, DecodesLiteral) {
{ {
const char kData[] = { const char kData[] = {
0x00, 0x00, 0x00, 0x01, // Error: PROTOCOL_ERROR '\x00', '\x00', '\x00', '\x01', // Error: PROTOCOL_ERROR
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -197,7 +197,8 @@ TEST_F(RstStreamFieldsDecoderTest, DecodesLiteral) { ...@@ -197,7 +197,8 @@ TEST_F(RstStreamFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, // Error: max uint32 (Unknown error code) '\xff', '\xff', '\xff',
'\xff', // Error: max uint32 (Unknown error code)
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -219,8 +220,8 @@ class SettingFieldsDecoderTest ...@@ -219,8 +220,8 @@ class SettingFieldsDecoderTest
TEST_F(SettingFieldsDecoderTest, DecodesLiteral) { TEST_F(SettingFieldsDecoderTest, DecodesLiteral) {
{ {
const char kData[] = { const char kData[] = {
0x00, 0x01, // Setting: HEADER_TABLE_SIZE '\x00', '\x01', // Setting: HEADER_TABLE_SIZE
0x00, 0x00, 0x40, 0x00, // Value: 16K '\x00', '\x00', '\x40', '\x00', // Value: 16K
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -232,8 +233,8 @@ TEST_F(SettingFieldsDecoderTest, DecodesLiteral) { ...@@ -232,8 +233,8 @@ TEST_F(SettingFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0x00, 0x00, // Setting: Unknown (0) '\x00', '\x00', // Setting: Unknown (0)
0xffu, 0xffu, 0xffu, 0xffu, // Value: max uint32 '\xff', '\xff', '\xff', '\xff', // Value: max uint32
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -255,7 +256,7 @@ class PushPromiseFieldsDecoderTest ...@@ -255,7 +256,7 @@ class PushPromiseFieldsDecoderTest
TEST_F(PushPromiseFieldsDecoderTest, DecodesLiteral) { TEST_F(PushPromiseFieldsDecoderTest, DecodesLiteral) {
{ {
const char kData[] = { const char kData[] = {
0x00, 0x01, 0x8au, 0x92u, // Promised Stream ID: 101010 '\x00', '\x01', '\x8a', '\x92', // Promised Stream ID: 101010
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -266,7 +267,8 @@ TEST_F(PushPromiseFieldsDecoderTest, DecodesLiteral) { ...@@ -266,7 +267,8 @@ TEST_F(PushPromiseFieldsDecoderTest, DecodesLiteral) {
// Promised stream id has R-bit (reserved for future use) set, which // Promised stream id has R-bit (reserved for future use) set, which
// should be cleared by the decoder. // should be cleared by the decoder.
const char kData[] = { const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, // Promised Stream ID: max uint31 and R-bit '\xff', '\xff', '\xff',
'\xff', // Promised Stream ID: max uint31 and R-bit
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -287,7 +289,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) { ...@@ -287,7 +289,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) {
{ {
// Each byte is different, so can detect if order changed. // Each byte is different, so can detect if order changed.
const char kData[] = { const char kData[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -298,7 +300,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) { ...@@ -298,7 +300,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) {
{ {
// All zeros, detect problems handling NULs. // All zeros, detect problems handling NULs.
const char kData[] = { const char kData[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -308,7 +310,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) { ...@@ -308,7 +310,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -330,8 +332,8 @@ class GoAwayFieldsDecoderTest : public StructureDecoderTest<Http2GoAwayFields> { ...@@ -330,8 +332,8 @@ class GoAwayFieldsDecoderTest : public StructureDecoderTest<Http2GoAwayFields> {
TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) { TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) {
{ {
const char kData[] = { const char kData[] = {
0x00, 0x00, 0x00, 0x00, // Last Stream ID: 0 '\x00', '\x00', '\x00', '\x00', // Last Stream ID: 0
0x00, 0x00, 0x00, 0x00, // Error: NO_ERROR (0) '\x00', '\x00', '\x00', '\x00', // Error: NO_ERROR (0)
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -342,8 +344,8 @@ TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) { ...@@ -342,8 +344,8 @@ TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0x00, 0x00, 0x00, 0x01, // Last Stream ID: 1 '\x00', '\x00', '\x00', '\x01', // Last Stream ID: 1
0x00, 0x00, 0x00, 0x0d, // Error: HTTP_1_1_REQUIRED '\x00', '\x00', '\x00', '\x0d', // Error: HTTP_1_1_REQUIRED
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -354,8 +356,10 @@ TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) { ...@@ -354,8 +356,10 @@ TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, // Last Stream ID: max uint31 and R-bit '\xff', '\xff',
0xffu, 0xffu, 0xffu, 0xffu, // Error: max uint32 (Unknown error code) '\xff', '\xff', // Last Stream ID: max uint31 and R-bit
'\xff', '\xff',
'\xff', '\xff', // Error: max uint32 (Unknown error code)
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -378,7 +382,7 @@ class WindowUpdateFieldsDecoderTest ...@@ -378,7 +382,7 @@ class WindowUpdateFieldsDecoderTest
TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) { TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) {
{ {
const char kData[] = { const char kData[] = {
0x00, 0x01, 0x00, 0x00, // Window Size Increment: 2 ^ 16 '\x00', '\x01', '\x00', '\x00', // Window Size Increment: 2 ^ 16
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -389,7 +393,7 @@ TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) { ...@@ -389,7 +393,7 @@ TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) {
// Increment must be non-zero, but we need to be able to decode the invalid // Increment must be non-zero, but we need to be able to decode the invalid
// zero to detect it. // zero to detect it.
const char kData[] = { const char kData[] = {
0x00, 0x00, 0x00, 0x00, // Window Size Increment: 0 '\x00', '\x00', '\x00', '\x00', // Window Size Increment: 0
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -402,7 +406,7 @@ TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) { ...@@ -402,7 +406,7 @@ TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) {
// clang-format off // clang-format off
const char kData[] = { const char kData[] = {
// Window Size Increment: max uint31 and R-bit // Window Size Increment: max uint31 and R-bit
0xffu, 0xffu, 0xffu, 0xffu, '\xff', '\xff', '\xff', '\xff',
}; };
// clang-format on // clang-format on
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
...@@ -424,7 +428,7 @@ class AltSvcFieldsDecoderTest : public StructureDecoderTest<Http2AltSvcFields> { ...@@ -424,7 +428,7 @@ class AltSvcFieldsDecoderTest : public StructureDecoderTest<Http2AltSvcFields> {
TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) { TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) {
{ {
const char kData[] = { const char kData[] = {
0x00, 0x00, // Origin Length: 0 '\x00', '\x00', // Origin Length: 0
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -433,7 +437,7 @@ TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) { ...@@ -433,7 +437,7 @@ TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0x00, 0x14, // Origin Length: 20 '\x00', '\x14', // Origin Length: 20
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
...@@ -442,7 +446,7 @@ TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) { ...@@ -442,7 +446,7 @@ TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) {
} }
{ {
const char kData[] = { const char kData[] = {
0xffu, 0xffu, // Origin Length: uint16 max '\xff', '\xff', // Origin Length: uint16 max
}; };
DecodeLeadingStructure(kData); DecodeLeadingStructure(kData);
if (!HasFailure()) { if (!HasFailure()) {
......
...@@ -226,10 +226,11 @@ class Http2FrameDecoderTest : public RandomDecoderTest { ...@@ -226,10 +226,11 @@ class Http2FrameDecoderTest : public RandomDecoderTest {
TEST_F(Http2FrameDecoderTest, DataEmpty) { TEST_F(Http2FrameDecoderTest, DataEmpty) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Payload length: 0 '\x00', '\x00', '\x00', // Payload length: 0
0x00, // DATA '\x00', // DATA
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x00, // Stream ID: 0 (invalid but unchecked here) '\x00', '\x00', '\x00',
'\x00', // Stream ID: 0 (invalid but unchecked here)
}; };
Http2FrameHeader header(0, Http2FrameType::DATA, 0, 0); Http2FrameHeader header(0, Http2FrameType::DATA, 0, 0);
FrameParts expected(header, ""); FrameParts expected(header, "");
...@@ -238,10 +239,10 @@ TEST_F(Http2FrameDecoderTest, DataEmpty) { ...@@ -238,10 +239,10 @@ TEST_F(Http2FrameDecoderTest, DataEmpty) {
TEST_F(Http2FrameDecoderTest, HeadersEmpty) { TEST_F(Http2FrameDecoderTest, HeadersEmpty) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Payload length: 0 '\x00', '\x00', '\x00', // Payload length: 0
0x01, // HEADERS '\x01', // HEADERS
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x01, // Stream ID: 0 (REQUIRES ID) '\x00', '\x00', '\x00', '\x01', // Stream ID: 0 (REQUIRES ID)
}; };
Http2FrameHeader header(0, Http2FrameType::HEADERS, 0, 1); Http2FrameHeader header(0, Http2FrameType::HEADERS, 0, 1);
FrameParts expected(header, ""); FrameParts expected(header, "");
...@@ -250,12 +251,12 @@ TEST_F(Http2FrameDecoderTest, HeadersEmpty) { ...@@ -250,12 +251,12 @@ TEST_F(Http2FrameDecoderTest, HeadersEmpty) {
TEST_F(Http2FrameDecoderTest, Priority) { TEST_F(Http2FrameDecoderTest, Priority) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x05, // Length: 5 '\x00', '\x00', '\x05', // Length: 5
0x02, // Type: PRIORITY '\x02', // Type: PRIORITY
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x02, // Stream: 2 '\x00', '\x00', '\x00', '\x02', // Stream: 2
0x80u, 0x00, 0x00, 0x01, // Parent: 1 (Exclusive) '\x80', '\x00', '\x00', '\x01', // Parent: 1 (Exclusive)
0x10, // Weight: 17 '\x10', // Weight: 17
}; };
Http2FrameHeader header(5, Http2FrameType::PRIORITY, 0, 2); Http2FrameHeader header(5, Http2FrameType::PRIORITY, 0, 2);
FrameParts expected(header); FrameParts expected(header);
...@@ -265,11 +266,11 @@ TEST_F(Http2FrameDecoderTest, Priority) { ...@@ -265,11 +266,11 @@ TEST_F(Http2FrameDecoderTest, Priority) {
TEST_F(Http2FrameDecoderTest, RstStream) { TEST_F(Http2FrameDecoderTest, RstStream) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x04, // Length: 4 '\x00', '\x00', '\x04', // Length: 4
0x03, // Type: RST_STREAM '\x03', // Type: RST_STREAM
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x01, // Stream: 1 '\x00', '\x00', '\x00', '\x01', // Stream: 1
0x00, 0x00, 0x00, 0x01, // Error: PROTOCOL_ERROR '\x00', '\x00', '\x00', '\x01', // Error: PROTOCOL_ERROR
}; };
Http2FrameHeader header(4, Http2FrameType::RST_STREAM, 0, 1); Http2FrameHeader header(4, Http2FrameType::RST_STREAM, 0, 1);
FrameParts expected(header); FrameParts expected(header);
...@@ -279,10 +280,10 @@ TEST_F(Http2FrameDecoderTest, RstStream) { ...@@ -279,10 +280,10 @@ TEST_F(Http2FrameDecoderTest, RstStream) {
TEST_F(Http2FrameDecoderTest, SettingsEmpty) { TEST_F(Http2FrameDecoderTest, SettingsEmpty) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Length: 0 '\x00', '\x00', '\x00', // Length: 0
0x04, // Type: SETTINGS '\x04', // Type: SETTINGS
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x01, // Stream: 1 (invalid but unchecked here) '\x00', '\x00', '\x00', '\x01', // Stream: 1 (invalid but unchecked here)
}; };
Http2FrameHeader header(0, Http2FrameType::SETTINGS, 0, 1); Http2FrameHeader header(0, Http2FrameType::SETTINGS, 0, 1);
EXPECT_TRUE(DecodePayloadAndValidateSeveralWays(kFrameData, header)); EXPECT_TRUE(DecodePayloadAndValidateSeveralWays(kFrameData, header));
...@@ -290,10 +291,10 @@ TEST_F(Http2FrameDecoderTest, SettingsEmpty) { ...@@ -290,10 +291,10 @@ TEST_F(Http2FrameDecoderTest, SettingsEmpty) {
TEST_F(Http2FrameDecoderTest, SettingsAck) { TEST_F(Http2FrameDecoderTest, SettingsAck) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Length: 6 '\x00', '\x00', '\x00', // Length: 6
0x04, // Type: SETTINGS '\x04', // Type: SETTINGS
0x01, // Flags: ACK '\x01', // Flags: ACK
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
}; };
Http2FrameHeader header(0, Http2FrameType::SETTINGS, Http2FrameFlag::ACK, 0); Http2FrameHeader header(0, Http2FrameType::SETTINGS, Http2FrameFlag::ACK, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -302,11 +303,13 @@ TEST_F(Http2FrameDecoderTest, SettingsAck) { ...@@ -302,11 +303,13 @@ TEST_F(Http2FrameDecoderTest, SettingsAck) {
TEST_F(Http2FrameDecoderTest, PushPromiseMinimal) { TEST_F(Http2FrameDecoderTest, PushPromiseMinimal) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x04, // Payload length: 4 '\x00', '\x00', '\x04', // Payload length: 4
0x05, // PUSH_PROMISE '\x05', // PUSH_PROMISE
0x04, // Flags: END_HEADERS '\x04', // Flags: END_HEADERS
0x00, 0x00, 0x00, 0x02, // Stream: 2 (invalid but unchecked here) '\x00', '\x00', '\x00',
0x00, 0x00, 0x00, 0x01, // Promised: 1 (invalid but unchecked here) '\x02', // Stream: 2 (invalid but unchecked here)
'\x00', '\x00', '\x00',
'\x01', // Promised: 1 (invalid but unchecked here)
}; };
Http2FrameHeader header(4, Http2FrameType::PUSH_PROMISE, Http2FrameHeader header(4, Http2FrameType::PUSH_PROMISE,
Http2FrameFlag::END_HEADERS, 2); Http2FrameFlag::END_HEADERS, 2);
...@@ -317,12 +320,12 @@ TEST_F(Http2FrameDecoderTest, PushPromiseMinimal) { ...@@ -317,12 +320,12 @@ TEST_F(Http2FrameDecoderTest, PushPromiseMinimal) {
TEST_F(Http2FrameDecoderTest, Ping) { TEST_F(Http2FrameDecoderTest, Ping) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x08, // Length: 8 '\x00', '\x00', '\x08', // Length: 8
0x06, // Type: PING '\x06', // Type: PING
0xfeu, // Flags: no valid flags '\xfe', // Flags: no valid flags
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
's', 'o', 'm', 'e', // "some" 's', 'o', 'm', 'e', // "some"
'd', 'a', 't', 'a', // "data" 'd', 'a', 't', 'a', // "data"
}; };
Http2FrameHeader header(8, Http2FrameType::PING, 0, 0); Http2FrameHeader header(8, Http2FrameType::PING, 0, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -333,12 +336,12 @@ TEST_F(Http2FrameDecoderTest, Ping) { ...@@ -333,12 +336,12 @@ TEST_F(Http2FrameDecoderTest, Ping) {
TEST_F(Http2FrameDecoderTest, PingAck) { TEST_F(Http2FrameDecoderTest, PingAck) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x08, // Length: 8 '\x00', '\x00', '\x08', // Length: 8
0x06, // Type: PING '\x06', // Type: PING
0xffu, // Flags: ACK (plus all invalid flags) '\xff', // Flags: ACK (plus all invalid flags)
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
's', 'o', 'm', 'e', // "some" 's', 'o', 'm', 'e', // "some"
'd', 'a', 't', 'a', // "data" 'd', 'a', 't', 'a', // "data"
}; };
Http2FrameHeader header(8, Http2FrameType::PING, Http2FrameFlag::ACK, 0); Http2FrameHeader header(8, Http2FrameType::PING, Http2FrameFlag::ACK, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -349,12 +352,12 @@ TEST_F(Http2FrameDecoderTest, PingAck) { ...@@ -349,12 +352,12 @@ TEST_F(Http2FrameDecoderTest, PingAck) {
TEST_F(Http2FrameDecoderTest, GoAwayMinimal) { TEST_F(Http2FrameDecoderTest, GoAwayMinimal) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x08, // Length: 8 (no opaque data) '\x00', '\x00', '\x08', // Length: 8 (no opaque data)
0x07, // Type: GOAWAY '\x07', // Type: GOAWAY
0xffu, // Flags: 0xff (no valid flags) '\xff', // Flags: 0xff (no valid flags)
0x00, 0x00, 0x00, 0x01, // Stream: 1 (invalid but unchecked here) '\x00', '\x00', '\x00', '\x01', // Stream: 1 (invalid but unchecked here)
0x80u, 0x00, 0x00, 0xffu, // Last: 255 (plus R bit) '\x80', '\x00', '\x00', '\xff', // Last: 255 (plus R bit)
0x00, 0x00, 0x00, 0x09, // Error: COMPRESSION_ERROR '\x00', '\x00', '\x00', '\x09', // Error: COMPRESSION_ERROR
}; };
Http2FrameHeader header(8, Http2FrameType::GOAWAY, 0, 1); Http2FrameHeader header(8, Http2FrameType::GOAWAY, 0, 1);
FrameParts expected(header); FrameParts expected(header);
...@@ -365,11 +368,11 @@ TEST_F(Http2FrameDecoderTest, GoAwayMinimal) { ...@@ -365,11 +368,11 @@ TEST_F(Http2FrameDecoderTest, GoAwayMinimal) {
TEST_F(Http2FrameDecoderTest, WindowUpdate) { TEST_F(Http2FrameDecoderTest, WindowUpdate) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x04, // Length: 4 '\x00', '\x00', '\x04', // Length: 4
0x08, // Type: WINDOW_UPDATE '\x08', // Type: WINDOW_UPDATE
0x0f, // Flags: 0xff (no valid flags) '\x0f', // Flags: 0xff (no valid flags)
0x00, 0x00, 0x00, 0x01, // Stream: 1 '\x00', '\x00', '\x00', '\x01', // Stream: 1
0x80u, 0x00, 0x04, 0x00, // Incr: 1024 (plus R bit) '\x80', '\x00', '\x04', '\x00', // Incr: 1024 (plus R bit)
}; };
Http2FrameHeader header(4, Http2FrameType::WINDOW_UPDATE, 0, 1); Http2FrameHeader header(4, Http2FrameType::WINDOW_UPDATE, 0, 1);
FrameParts expected(header); FrameParts expected(header);
...@@ -379,10 +382,11 @@ TEST_F(Http2FrameDecoderTest, WindowUpdate) { ...@@ -379,10 +382,11 @@ TEST_F(Http2FrameDecoderTest, WindowUpdate) {
TEST_F(Http2FrameDecoderTest, ContinuationEmpty) { TEST_F(Http2FrameDecoderTest, ContinuationEmpty) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Payload length: 0 '\x00', '\x00', '\x00', // Payload length: 0
0x09, // CONTINUATION '\x09', // CONTINUATION
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x00, // Stream ID: 0 (invalid but unchecked here) '\x00', '\x00', '\x00',
'\x00', // Stream ID: 0 (invalid but unchecked here)
}; };
Http2FrameHeader header(0, Http2FrameType::CONTINUATION, 0, 0); Http2FrameHeader header(0, Http2FrameType::CONTINUATION, 0, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -391,11 +395,12 @@ TEST_F(Http2FrameDecoderTest, ContinuationEmpty) { ...@@ -391,11 +395,12 @@ TEST_F(Http2FrameDecoderTest, ContinuationEmpty) {
TEST_F(Http2FrameDecoderTest, AltSvcMinimal) { TEST_F(Http2FrameDecoderTest, AltSvcMinimal) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x02, // Payload length: 2 '\x00', '\x00', '\x02', // Payload length: 2
0x0a, // ALTSVC '\x0a', // ALTSVC
0xffu, // Flags: none (plus 0xff) '\xff', // Flags: none (plus 0xff)
0x00, 0x00, 0x00, 0x00, // Stream ID: 0 (invalid but unchecked here) '\x00', '\x00', '\x00',
0x00, 0x00, // Origin Length: 0 '\x00', // Stream ID: 0 (invalid but unchecked here)
'\x00', '\x00', // Origin Length: 0
}; };
Http2FrameHeader header(2, Http2FrameType::ALTSVC, 0, 0); Http2FrameHeader header(2, Http2FrameType::ALTSVC, 0, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -406,10 +411,10 @@ TEST_F(Http2FrameDecoderTest, AltSvcMinimal) { ...@@ -406,10 +411,10 @@ TEST_F(Http2FrameDecoderTest, AltSvcMinimal) {
TEST_F(Http2FrameDecoderTest, UnknownEmpty) { TEST_F(Http2FrameDecoderTest, UnknownEmpty) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Payload length: 0 '\x00', '\x00', '\x00', // Payload length: 0
0x20, // 32 (unknown) '\x20', // 32 (unknown)
0xffu, // Flags: all '\xff', // Flags: all
0x00, 0x00, 0x00, 0x00, // Stream ID: 0 '\x00', '\x00', '\x00', '\x00', // Stream ID: 0
}; };
Http2FrameHeader header(0, static_cast<Http2FrameType>(32), 0xff, 0); Http2FrameHeader header(0, static_cast<Http2FrameType>(32), 0xff, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -421,11 +426,11 @@ TEST_F(Http2FrameDecoderTest, UnknownEmpty) { ...@@ -421,11 +426,11 @@ TEST_F(Http2FrameDecoderTest, UnknownEmpty) {
TEST_F(Http2FrameDecoderTest, DataPayload) { TEST_F(Http2FrameDecoderTest, DataPayload) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x03, // Payload length: 7 '\x00', '\x00', '\x03', // Payload length: 7
0x00, // DATA '\x00', // DATA
0x80u, // Flags: 0x80 '\x80', // Flags: 0x80
0x00, 0x00, 0x02, 0x02, // Stream ID: 514 '\x00', '\x00', '\x02', '\x02', // Stream ID: 514
'a', 'b', 'c', // Data 'a', 'b', 'c', // Data
}; };
Http2FrameHeader header(3, Http2FrameType::DATA, 0, 514); Http2FrameHeader header(3, Http2FrameType::DATA, 0, 514);
FrameParts expected(header, "abc"); FrameParts expected(header, "abc");
...@@ -434,11 +439,11 @@ TEST_F(Http2FrameDecoderTest, DataPayload) { ...@@ -434,11 +439,11 @@ TEST_F(Http2FrameDecoderTest, DataPayload) {
TEST_F(Http2FrameDecoderTest, HeadersPayload) { TEST_F(Http2FrameDecoderTest, HeadersPayload) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x03, // Payload length: 3 '\x00', '\x00', '\x03', // Payload length: 3
0x01, // HEADERS '\x01', // HEADERS
0x05, // Flags: END_STREAM | END_HEADERS '\x05', // Flags: END_STREAM | END_HEADERS
0x00, 0x00, 0x00, 0x02, // Stream ID: 0 (REQUIRES ID) '\x00', '\x00', '\x00', '\x02', // Stream ID: 0 (REQUIRES ID)
'a', 'b', 'c', // HPACK fragment (doesn't have to be valid) 'a', 'b', 'c', // HPACK fragment (doesn't have to be valid)
}; };
Http2FrameHeader header( Http2FrameHeader header(
3, Http2FrameType::HEADERS, 3, Http2FrameType::HEADERS,
...@@ -449,12 +454,12 @@ TEST_F(Http2FrameDecoderTest, HeadersPayload) { ...@@ -449,12 +454,12 @@ TEST_F(Http2FrameDecoderTest, HeadersPayload) {
TEST_F(Http2FrameDecoderTest, HeadersPriority) { TEST_F(Http2FrameDecoderTest, HeadersPriority) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x05, // Payload length: 5 '\x00', '\x00', '\x05', // Payload length: 5
0x01, // HEADERS '\x01', // HEADERS
0x20, // Flags: PRIORITY '\x20', // Flags: PRIORITY
0x00, 0x00, 0x00, 0x02, // Stream ID: 0 (REQUIRES ID) '\x00', '\x00', '\x00', '\x02', // Stream ID: 0 (REQUIRES ID)
0x00, 0x00, 0x00, 0x01, // Parent: 1 (Not Exclusive) '\x00', '\x00', '\x00', '\x01', // Parent: 1 (Not Exclusive)
0xffu, // Weight: 256 '\xff', // Weight: 256
}; };
Http2FrameHeader header(5, Http2FrameType::HEADERS, Http2FrameFlag::PRIORITY, Http2FrameHeader header(5, Http2FrameType::HEADERS, Http2FrameFlag::PRIORITY,
2); 2);
...@@ -465,14 +470,14 @@ TEST_F(Http2FrameDecoderTest, HeadersPriority) { ...@@ -465,14 +470,14 @@ TEST_F(Http2FrameDecoderTest, HeadersPriority) {
TEST_F(Http2FrameDecoderTest, Settings) { TEST_F(Http2FrameDecoderTest, Settings) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x0c, // Length: 12 '\x00', '\x00', '\x0c', // Length: 12
0x04, // Type: SETTINGS '\x04', // Type: SETTINGS
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
0x00, 0x04, // Param: INITIAL_WINDOW_SIZE '\x00', '\x04', // Param: INITIAL_WINDOW_SIZE
0x0a, 0x0b, 0x0c, 0x0d, // Value: 168496141 '\x0a', '\x0b', '\x0c', '\x0d', // Value: 168496141
0x00, 0x02, // Param: ENABLE_PUSH '\x00', '\x02', // Param: ENABLE_PUSH
0x00, 0x00, 0x00, 0x03, // Value: 3 (invalid but unchecked here) '\x00', '\x00', '\x00', '\x03', // Value: 3 (invalid but unchecked here)
}; };
Http2FrameHeader header(12, Http2FrameType::SETTINGS, 0, 0); Http2FrameHeader header(12, Http2FrameType::SETTINGS, 0, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -485,12 +490,12 @@ TEST_F(Http2FrameDecoderTest, Settings) { ...@@ -485,12 +490,12 @@ TEST_F(Http2FrameDecoderTest, Settings) {
TEST_F(Http2FrameDecoderTest, PushPromisePayload) { TEST_F(Http2FrameDecoderTest, PushPromisePayload) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 7, // Payload length: 7 '\x00', '\x00', 7, // Payload length: 7
0x05, // PUSH_PROMISE '\x05', // PUSH_PROMISE
0x04, // Flags: END_HEADERS '\x04', // Flags: END_HEADERS
0x00, 0x00, 0x00, 0xffu, // Stream ID: 255 '\x00', '\x00', '\x00', '\xff', // Stream ID: 255
0x00, 0x00, 0x01, 0x00, // Promised: 256 '\x00', '\x00', '\x01', '\x00', // Promised: 256
'a', 'b', 'c', // HPACK fragment (doesn't have to be valid) 'a', 'b', 'c', // HPACK fragment (doesn't have to be valid)
}; };
Http2FrameHeader header(7, Http2FrameType::PUSH_PROMISE, Http2FrameHeader header(7, Http2FrameType::PUSH_PROMISE,
Http2FrameFlag::END_HEADERS, 255); Http2FrameFlag::END_HEADERS, 255);
...@@ -501,13 +506,13 @@ TEST_F(Http2FrameDecoderTest, PushPromisePayload) { ...@@ -501,13 +506,13 @@ TEST_F(Http2FrameDecoderTest, PushPromisePayload) {
TEST_F(Http2FrameDecoderTest, GoAwayOpaqueData) { TEST_F(Http2FrameDecoderTest, GoAwayOpaqueData) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x0e, // Length: 14 '\x00', '\x00', '\x0e', // Length: 14
0x07, // Type: GOAWAY '\x07', // Type: GOAWAY
0xffu, // Flags: 0xff (no valid flags) '\xff', // Flags: 0xff (no valid flags)
0x80u, 0x00, 0x00, 0x00, // Stream: 0 (plus R bit) '\x80', '\x00', '\x00', '\x00', // Stream: 0 (plus R bit)
0x00, 0x00, 0x01, 0x00, // Last: 256 '\x00', '\x00', '\x01', '\x00', // Last: 256
0x00, 0x00, 0x00, 0x03, // Error: FLOW_CONTROL_ERROR '\x00', '\x00', '\x00', '\x03', // Error: FLOW_CONTROL_ERROR
'o', 'p', 'a', 'q', 'u', 'e', 'o', 'p', 'a', 'q', 'u', 'e',
}; };
Http2FrameHeader header(14, Http2FrameType::GOAWAY, 0, 0); Http2FrameHeader header(14, Http2FrameType::GOAWAY, 0, 0);
FrameParts expected(header, "opaque"); FrameParts expected(header, "opaque");
...@@ -518,11 +523,11 @@ TEST_F(Http2FrameDecoderTest, GoAwayOpaqueData) { ...@@ -518,11 +523,11 @@ TEST_F(Http2FrameDecoderTest, GoAwayOpaqueData) {
TEST_F(Http2FrameDecoderTest, ContinuationPayload) { TEST_F(Http2FrameDecoderTest, ContinuationPayload) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x03, // Payload length: 3 '\x00', '\x00', '\x03', // Payload length: 3
0x09, // CONTINUATION '\x09', // CONTINUATION
0xffu, // Flags: END_HEADERS | 0xfb '\xff', // Flags: END_HEADERS | 0xfb
0x00, 0x00, 0x00, 0x02, // Stream ID: 2 '\x00', '\x00', '\x00', '\x02', // Stream ID: 2
'a', 'b', 'c', // Data 'a', 'b', 'c', // Data
}; };
Http2FrameHeader header(3, Http2FrameType::CONTINUATION, Http2FrameHeader header(3, Http2FrameType::CONTINUATION,
Http2FrameFlag::END_HEADERS, 2); Http2FrameFlag::END_HEADERS, 2);
...@@ -532,13 +537,13 @@ TEST_F(Http2FrameDecoderTest, ContinuationPayload) { ...@@ -532,13 +537,13 @@ TEST_F(Http2FrameDecoderTest, ContinuationPayload) {
TEST_F(Http2FrameDecoderTest, AltSvcPayload) { TEST_F(Http2FrameDecoderTest, AltSvcPayload) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x08, // Payload length: 3 '\x00', '\x00', '\x08', // Payload length: 3
0x0a, // ALTSVC '\x0a', // ALTSVC
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x02, // Stream ID: 2 '\x00', '\x00', '\x00', '\x02', // Stream ID: 2
0x00, 0x03, // Origin Length: 0 '\x00', '\x03', // Origin Length: 0
'a', 'b', 'c', // Origin 'a', 'b', 'c', // Origin
'd', 'e', 'f', // Value 'd', 'e', 'f', // Value
}; };
Http2FrameHeader header(8, Http2FrameType::ALTSVC, 0, 2); Http2FrameHeader header(8, Http2FrameType::ALTSVC, 0, 2);
FrameParts expected(header); FrameParts expected(header);
...@@ -548,11 +553,11 @@ TEST_F(Http2FrameDecoderTest, AltSvcPayload) { ...@@ -548,11 +553,11 @@ TEST_F(Http2FrameDecoderTest, AltSvcPayload) {
TEST_F(Http2FrameDecoderTest, UnknownPayload) { TEST_F(Http2FrameDecoderTest, UnknownPayload) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x03, // Payload length: 3 '\x00', '\x00', '\x03', // Payload length: 3
0x30, // 48 (unknown) '\x30', // 48 (unknown)
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x02, // Stream ID: 2 '\x00', '\x00', '\x00', '\x02', // Stream ID: 2
'a', 'b', 'c', // Payload 'a', 'b', 'c', // Payload
}; };
Http2FrameHeader header(3, static_cast<Http2FrameType>(48), 0, 2); Http2FrameHeader header(3, static_cast<Http2FrameType>(48), 0, 2);
FrameParts expected(header, "abc"); FrameParts expected(header, "abc");
...@@ -564,13 +569,13 @@ TEST_F(Http2FrameDecoderTest, UnknownPayload) { ...@@ -564,13 +569,13 @@ TEST_F(Http2FrameDecoderTest, UnknownPayload) {
TEST_F(Http2FrameDecoderTest, DataPayloadAndPadding) { TEST_F(Http2FrameDecoderTest, DataPayloadAndPadding) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x07, // Payload length: 7 '\x00', '\x00', '\x07', // Payload length: 7
0x00, // DATA '\x00', // DATA
0x09, // Flags: END_STREAM | PADDED '\x09', // Flags: END_STREAM | PADDED
0x00, 0x00, 0x00, 0x02, // Stream ID: 0 (REQUIRES ID) '\x00', '\x00', '\x00', '\x02', // Stream ID: 0 (REQUIRES ID)
0x03, // Pad Len '\x03', // Pad Len
'a', 'b', 'c', // Data 'a', 'b', 'c', // Data
0x00, 0x00, 0x00, // Padding '\x00', '\x00', '\x00', // Padding
}; };
Http2FrameHeader header(7, Http2FrameType::DATA, Http2FrameHeader header(7, Http2FrameType::DATA,
Http2FrameFlag::END_STREAM | Http2FrameFlag::PADDED, Http2FrameFlag::END_STREAM | Http2FrameFlag::PADDED,
...@@ -582,13 +587,13 @@ TEST_F(Http2FrameDecoderTest, DataPayloadAndPadding) { ...@@ -582,13 +587,13 @@ TEST_F(Http2FrameDecoderTest, DataPayloadAndPadding) {
TEST_F(Http2FrameDecoderTest, HeadersPayloadAndPadding) { TEST_F(Http2FrameDecoderTest, HeadersPayloadAndPadding) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x07, // Payload length: 7 '\x00', '\x00', '\x07', // Payload length: 7
0x01, // HEADERS '\x01', // HEADERS
0x08, // Flags: PADDED '\x08', // Flags: PADDED
0x00, 0x00, 0x00, 0x02, // Stream ID: 0 (REQUIRES ID) '\x00', '\x00', '\x00', '\x02', // Stream ID: 0 (REQUIRES ID)
0x03, // Pad Len '\x03', // Pad Len
'a', 'b', 'c', // HPACK fragment (doesn't have to be valid) 'a', 'b', 'c', // HPACK fragment (doesn't have to be valid)
0x00, 0x00, 0x00, // Padding '\x00', '\x00', '\x00', // Padding
}; };
Http2FrameHeader header(7, Http2FrameType::HEADERS, Http2FrameFlag::PADDED, Http2FrameHeader header(7, Http2FrameType::HEADERS, Http2FrameFlag::PADDED,
2); 2);
...@@ -599,15 +604,15 @@ TEST_F(Http2FrameDecoderTest, HeadersPayloadAndPadding) { ...@@ -599,15 +604,15 @@ TEST_F(Http2FrameDecoderTest, HeadersPayloadAndPadding) {
TEST_F(Http2FrameDecoderTest, HeadersPayloadPriorityAndPadding) { TEST_F(Http2FrameDecoderTest, HeadersPayloadPriorityAndPadding) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x0c, // Payload length: 12 '\x00', '\x00', '\x0c', // Payload length: 12
0x01, // HEADERS '\x01', // HEADERS
0xffu, // Flags: all, including undefined '\xff', // Flags: all, including undefined
0x00, 0x00, 0x00, 0x02, // Stream ID: 0 (REQUIRES ID) '\x00', '\x00', '\x00', '\x02', // Stream ID: 0 (REQUIRES ID)
0x03, // Pad Len '\x03', // Pad Len
0x80u, 0x00, 0x00, 0x01, // Parent: 1 (Exclusive) '\x80', '\x00', '\x00', '\x01', // Parent: 1 (Exclusive)
0x10, // Weight: 17 '\x10', // Weight: 17
'a', 'b', 'c', // HPACK fragment (doesn't have to be valid) 'a', 'b', 'c', // HPACK fragment (doesn't have to be valid)
0x00, 0x00, 0x00, // Padding '\x00', '\x00', '\x00', // Padding
}; };
Http2FrameHeader header(12, Http2FrameType::HEADERS, Http2FrameHeader header(12, Http2FrameType::HEADERS,
Http2FrameFlag::END_STREAM | Http2FrameFlag::END_STREAM |
...@@ -622,14 +627,14 @@ TEST_F(Http2FrameDecoderTest, HeadersPayloadPriorityAndPadding) { ...@@ -622,14 +627,14 @@ TEST_F(Http2FrameDecoderTest, HeadersPayloadPriorityAndPadding) {
TEST_F(Http2FrameDecoderTest, PushPromisePayloadAndPadding) { TEST_F(Http2FrameDecoderTest, PushPromisePayloadAndPadding) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 11, // Payload length: 11 '\x00', '\x00', 11, // Payload length: 11
0x05, // PUSH_PROMISE '\x05', // PUSH_PROMISE
0xffu, // Flags: END_HEADERS | PADDED | 0xf3 '\xff', // Flags: END_HEADERS | PADDED | 0xf3
0x00, 0x00, 0x00, 0x01, // Stream ID: 1 '\x00', '\x00', '\x00', '\x01', // Stream ID: 1
0x03, // Pad Len '\x03', // Pad Len
0x00, 0x00, 0x00, 0x02, // Promised: 2 '\x00', '\x00', '\x00', '\x02', // Promised: 2
'a', 'b', 'c', // HPACK fragment (doesn't have to be valid) 'a', 'b', 'c', // HPACK fragment (doesn't have to be valid)
0x00, 0x00, 0x00, // Padding '\x00', '\x00', '\x00', // Padding
}; };
Http2FrameHeader header(11, Http2FrameType::PUSH_PROMISE, Http2FrameHeader header(11, Http2FrameType::PUSH_PROMISE,
Http2FrameFlag::END_HEADERS | Http2FrameFlag::PADDED, Http2FrameFlag::END_HEADERS | Http2FrameFlag::PADDED,
...@@ -645,10 +650,10 @@ TEST_F(Http2FrameDecoderTest, PushPromisePayloadAndPadding) { ...@@ -645,10 +650,10 @@ TEST_F(Http2FrameDecoderTest, PushPromisePayloadAndPadding) {
TEST_F(Http2FrameDecoderTest, DataMissingPadLengthField) { TEST_F(Http2FrameDecoderTest, DataMissingPadLengthField) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Payload length: 0 '\x00', '\x00', '\x00', // Payload length: 0
0x00, // DATA '\x00', // DATA
0x08, // Flags: PADDED '\x08', // Flags: PADDED
0x00, 0x00, 0x00, 0x01, // Stream ID: 1 '\x00', '\x00', '\x00', '\x01', // Stream ID: 1
}; };
Http2FrameHeader header(0, Http2FrameType::DATA, Http2FrameFlag::PADDED, 1); Http2FrameHeader header(0, Http2FrameType::DATA, Http2FrameFlag::PADDED, 1);
FrameParts expected(header); FrameParts expected(header);
...@@ -658,12 +663,12 @@ TEST_F(Http2FrameDecoderTest, DataMissingPadLengthField) { ...@@ -658,12 +663,12 @@ TEST_F(Http2FrameDecoderTest, DataMissingPadLengthField) {
TEST_F(Http2FrameDecoderTest, HeaderPaddingTooLong) { TEST_F(Http2FrameDecoderTest, HeaderPaddingTooLong) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x02, // Payload length: 0 '\x00', '\x00', '\x02', // Payload length: 0
0x01, // HEADERS '\x01', // HEADERS
0x08, // Flags: PADDED '\x08', // Flags: PADDED
0x00, 0x01, 0x00, 0x00, // Stream ID: 65536 '\x00', '\x01', '\x00', '\x00', // Stream ID: 65536
0xffu, // Pad Len: 255 '\xff', // Pad Len: 255
0x00, // Only one byte of padding '\x00', // Only one byte of padding
}; };
Http2FrameHeader header(2, Http2FrameType::HEADERS, Http2FrameFlag::PADDED, Http2FrameHeader header(2, Http2FrameType::HEADERS, Http2FrameFlag::PADDED,
65536); 65536);
...@@ -674,11 +679,11 @@ TEST_F(Http2FrameDecoderTest, HeaderPaddingTooLong) { ...@@ -674,11 +679,11 @@ TEST_F(Http2FrameDecoderTest, HeaderPaddingTooLong) {
TEST_F(Http2FrameDecoderTest, HeaderMissingPriority) { TEST_F(Http2FrameDecoderTest, HeaderMissingPriority) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x04, // Payload length: 0 '\x00', '\x00', '\x04', // Payload length: 0
0x01, // HEADERS '\x01', // HEADERS
0x20, // Flags: PRIORITY '\x20', // Flags: PRIORITY
0x00, 0x01, 0x00, 0x00, // Stream ID: 65536 '\x00', '\x01', '\x00', '\x00', // Stream ID: 65536
0x00, 0x00, 0x00, 0x00, // Priority (truncated) '\x00', '\x00', '\x00', '\x00', // Priority (truncated)
}; };
Http2FrameHeader header(4, Http2FrameType::HEADERS, Http2FrameFlag::PRIORITY, Http2FrameHeader header(4, Http2FrameType::HEADERS, Http2FrameFlag::PRIORITY,
65536); 65536);
...@@ -687,11 +692,11 @@ TEST_F(Http2FrameDecoderTest, HeaderMissingPriority) { ...@@ -687,11 +692,11 @@ TEST_F(Http2FrameDecoderTest, HeaderMissingPriority) {
TEST_F(Http2FrameDecoderTest, PriorityTooShort) { TEST_F(Http2FrameDecoderTest, PriorityTooShort) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x04, // Length: 5 '\x00', '\x00', '\x04', // Length: 5
0x02, // Type: PRIORITY '\x02', // Type: PRIORITY
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x02, // Stream: 2 '\x00', '\x00', '\x00', '\x02', // Stream: 2
0x80u, 0x00, 0x00, 0x01, // Parent: 1 (Exclusive) '\x80', '\x00', '\x00', '\x01', // Parent: 1 (Exclusive)
}; };
Http2FrameHeader header(4, Http2FrameType::PRIORITY, 0, 2); Http2FrameHeader header(4, Http2FrameType::PRIORITY, 0, 2);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -699,11 +704,11 @@ TEST_F(Http2FrameDecoderTest, PriorityTooShort) { ...@@ -699,11 +704,11 @@ TEST_F(Http2FrameDecoderTest, PriorityTooShort) {
TEST_F(Http2FrameDecoderTest, RstStreamTooShort) { TEST_F(Http2FrameDecoderTest, RstStreamTooShort) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x03, // Length: 4 '\x00', '\x00', '\x03', // Length: 4
0x03, // Type: RST_STREAM '\x03', // Type: RST_STREAM
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x01, // Stream: 1 '\x00', '\x00', '\x00', '\x01', // Stream: 1
0x00, 0x00, 0x00, // Truncated '\x00', '\x00', '\x00', // Truncated
}; };
Http2FrameHeader header(3, Http2FrameType::RST_STREAM, 0, 1); Http2FrameHeader header(3, Http2FrameType::RST_STREAM, 0, 1);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -713,14 +718,14 @@ TEST_F(Http2FrameDecoderTest, RstStreamTooShort) { ...@@ -713,14 +718,14 @@ TEST_F(Http2FrameDecoderTest, RstStreamTooShort) {
// invalid. // invalid.
TEST_F(Http2FrameDecoderTest, SettingsWrongSize) { TEST_F(Http2FrameDecoderTest, SettingsWrongSize) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x09, // Length: 2 '\x00', '\x00', '\x09', // Length: 2
0x04, // Type: SETTINGS '\x04', // Type: SETTINGS
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
0x00, 0x02, // Param: ENABLE_PUSH '\x00', '\x02', // Param: ENABLE_PUSH
0x00, 0x00, 0x00, 0x03, // Value: 1 '\x00', '\x00', '\x00', '\x03', // Value: 1
0x00, 0x04, // Param: INITIAL_WINDOW_SIZE '\x00', '\x04', // Param: INITIAL_WINDOW_SIZE
0x00, // Value: Truncated '\x00', // Value: Truncated
}; };
Http2FrameHeader header(9, Http2FrameType::SETTINGS, 0, 0); Http2FrameHeader header(9, Http2FrameType::SETTINGS, 0, 0);
FrameParts expected(header); FrameParts expected(header);
...@@ -731,11 +736,11 @@ TEST_F(Http2FrameDecoderTest, SettingsWrongSize) { ...@@ -731,11 +736,11 @@ TEST_F(Http2FrameDecoderTest, SettingsWrongSize) {
TEST_F(Http2FrameDecoderTest, PushPromiseTooShort) { TEST_F(Http2FrameDecoderTest, PushPromiseTooShort) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 3, // Payload length: 3 '\x00', '\x00', 3, // Payload length: 3
0x05, // PUSH_PROMISE '\x05', // PUSH_PROMISE
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x01, // Stream ID: 1 '\x00', '\x00', '\x00', '\x01', // Stream ID: 1
0x00, 0x00, 0x00, // Truncated promise id '\x00', '\x00', '\x00', // Truncated promise id
}; };
Http2FrameHeader header(3, Http2FrameType::PUSH_PROMISE, 0, 1); Http2FrameHeader header(3, Http2FrameType::PUSH_PROMISE, 0, 1);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -743,12 +748,12 @@ TEST_F(Http2FrameDecoderTest, PushPromiseTooShort) { ...@@ -743,12 +748,12 @@ TEST_F(Http2FrameDecoderTest, PushPromiseTooShort) {
TEST_F(Http2FrameDecoderTest, PushPromisePaddedTruncatedPromise) { TEST_F(Http2FrameDecoderTest, PushPromisePaddedTruncatedPromise) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 4, // Payload length: 4 '\x00', '\x00', 4, // Payload length: 4
0x05, // PUSH_PROMISE '\x05', // PUSH_PROMISE
0x08, // Flags: PADDED '\x08', // Flags: PADDED
0x00, 0x00, 0x00, 0x01, // Stream ID: 1 '\x00', '\x00', '\x00', '\x01', // Stream ID: 1
0x00, // Pad Len '\x00', // Pad Len
0x00, 0x00, 0x00, // Truncated promise id '\x00', '\x00', '\x00', // Truncated promise id
}; };
Http2FrameHeader header(4, Http2FrameType::PUSH_PROMISE, Http2FrameHeader header(4, Http2FrameType::PUSH_PROMISE,
Http2FrameFlag::PADDED, 1); Http2FrameFlag::PADDED, 1);
...@@ -757,12 +762,12 @@ TEST_F(Http2FrameDecoderTest, PushPromisePaddedTruncatedPromise) { ...@@ -757,12 +762,12 @@ TEST_F(Http2FrameDecoderTest, PushPromisePaddedTruncatedPromise) {
TEST_F(Http2FrameDecoderTest, PingTooShort) { TEST_F(Http2FrameDecoderTest, PingTooShort) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x07, // Length: 8 '\x00', '\x00', '\x07', // Length: 8
0x06, // Type: PING '\x06', // Type: PING
0xfeu, // Flags: no valid flags '\xfe', // Flags: no valid flags
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
's', 'o', 'm', 'e', // "some" 's', 'o', 'm', 'e', // "some"
'd', 'a', 't', // Too little 'd', 'a', 't', // Too little
}; };
Http2FrameHeader header(7, Http2FrameType::PING, 0, 0); Http2FrameHeader header(7, Http2FrameType::PING, 0, 0);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -770,10 +775,10 @@ TEST_F(Http2FrameDecoderTest, PingTooShort) { ...@@ -770,10 +775,10 @@ TEST_F(Http2FrameDecoderTest, PingTooShort) {
TEST_F(Http2FrameDecoderTest, GoAwayTooShort) { TEST_F(Http2FrameDecoderTest, GoAwayTooShort) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x00, // Length: 0 '\x00', '\x00', '\x00', // Length: 0
0x07, // Type: GOAWAY '\x07', // Type: GOAWAY
0xffu, // Flags: 0xff (no valid flags) '\xff', // Flags: 0xff (no valid flags)
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
}; };
Http2FrameHeader header(0, Http2FrameType::GOAWAY, 0, 0); Http2FrameHeader header(0, Http2FrameType::GOAWAY, 0, 0);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -781,11 +786,11 @@ TEST_F(Http2FrameDecoderTest, GoAwayTooShort) { ...@@ -781,11 +786,11 @@ TEST_F(Http2FrameDecoderTest, GoAwayTooShort) {
TEST_F(Http2FrameDecoderTest, WindowUpdateTooShort) { TEST_F(Http2FrameDecoderTest, WindowUpdateTooShort) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x03, // Length: 3 '\x00', '\x00', '\x03', // Length: 3
0x08, // Type: WINDOW_UPDATE '\x08', // Type: WINDOW_UPDATE
0x0f, // Flags: 0xff (no valid flags) '\x0f', // Flags: 0xff (no valid flags)
0x00, 0x00, 0x00, 0x01, // Stream: 1 '\x00', '\x00', '\x00', '\x01', // Stream: 1
0x80u, 0x00, 0x04, // Truncated '\x80', '\x00', '\x04', // Truncated
}; };
Http2FrameHeader header(3, Http2FrameType::WINDOW_UPDATE, 0, 1); Http2FrameHeader header(3, Http2FrameType::WINDOW_UPDATE, 0, 1);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -793,11 +798,11 @@ TEST_F(Http2FrameDecoderTest, WindowUpdateTooShort) { ...@@ -793,11 +798,11 @@ TEST_F(Http2FrameDecoderTest, WindowUpdateTooShort) {
TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOriginLength) { TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOriginLength) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x01, // Payload length: 3 '\x00', '\x00', '\x01', // Payload length: 3
0x0a, // ALTSVC '\x0a', // ALTSVC
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x02, // Stream ID: 2 '\x00', '\x00', '\x00', '\x02', // Stream ID: 2
0x00, // Origin Length: truncated '\x00', // Origin Length: truncated
}; };
Http2FrameHeader header(1, Http2FrameType::ALTSVC, 0, 2); Http2FrameHeader header(1, Http2FrameType::ALTSVC, 0, 2);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -805,12 +810,12 @@ TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOriginLength) { ...@@ -805,12 +810,12 @@ TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOriginLength) {
TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOrigin) { TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOrigin) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x05, // Payload length: 3 '\x00', '\x00', '\x05', // Payload length: 3
0x0a, // ALTSVC '\x0a', // ALTSVC
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x02, // Stream ID: 2 '\x00', '\x00', '\x00', '\x02', // Stream ID: 2
0x00, 0x04, // Origin Length: 4 (too long) '\x00', '\x04', // Origin Length: 4 (too long)
'a', 'b', 'c', // Origin 'a', 'b', 'c', // Origin
}; };
Http2FrameHeader header(5, Http2FrameType::ALTSVC, 0, 2); Http2FrameHeader header(5, Http2FrameType::ALTSVC, 0, 2);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -824,13 +829,13 @@ TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOrigin) { ...@@ -824,13 +829,13 @@ TEST_F(Http2FrameDecoderTest, AltSvcTruncatedOrigin) {
TEST_F(Http2FrameDecoderTest, BeyondMaximum) { TEST_F(Http2FrameDecoderTest, BeyondMaximum) {
decoder_.set_maximum_payload_size(2); decoder_.set_maximum_payload_size(2);
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x07, // Payload length: 7 '\x00', '\x00', '\x07', // Payload length: 7
0x00, // DATA '\x00', // DATA
0x09, // Flags: END_STREAM | PADDED '\x09', // Flags: END_STREAM | PADDED
0x00, 0x00, 0x00, 0x02, // Stream ID: 0 (REQUIRES ID) '\x00', '\x00', '\x00', '\x02', // Stream ID: 0 (REQUIRES ID)
0x03, // Pad Len '\x03', // Pad Len
'a', 'b', 'c', // Data 'a', 'b', 'c', // Data
0x00, 0x00, 0x00, // Padding '\x00', '\x00', '\x00', // Padding
}; };
Http2FrameHeader header(7, Http2FrameType::DATA, Http2FrameHeader header(7, Http2FrameType::DATA,
Http2FrameFlag::END_STREAM | Http2FrameFlag::PADDED, Http2FrameFlag::END_STREAM | Http2FrameFlag::PADDED,
...@@ -854,13 +859,13 @@ TEST_F(Http2FrameDecoderTest, BeyondMaximum) { ...@@ -854,13 +859,13 @@ TEST_F(Http2FrameDecoderTest, BeyondMaximum) {
TEST_F(Http2FrameDecoderTest, PriorityTooLong) { TEST_F(Http2FrameDecoderTest, PriorityTooLong) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x06, // Length: 5 '\x00', '\x00', '\x06', // Length: 5
0x02, // Type: PRIORITY '\x02', // Type: PRIORITY
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x02, // Stream: 2 '\x00', '\x00', '\x00', '\x02', // Stream: 2
0x80u, 0x00, 0x00, 0x01, // Parent: 1 (Exclusive) '\x80', '\x00', '\x00', '\x01', // Parent: 1 (Exclusive)
0x10, // Weight: 17 '\x10', // Weight: 17
0x00, // Too much '\x00', // Too much
}; };
Http2FrameHeader header(6, Http2FrameType::PRIORITY, 0, 2); Http2FrameHeader header(6, Http2FrameType::PRIORITY, 0, 2);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -868,12 +873,12 @@ TEST_F(Http2FrameDecoderTest, PriorityTooLong) { ...@@ -868,12 +873,12 @@ TEST_F(Http2FrameDecoderTest, PriorityTooLong) {
TEST_F(Http2FrameDecoderTest, RstStreamTooLong) { TEST_F(Http2FrameDecoderTest, RstStreamTooLong) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x05, // Length: 4 '\x00', '\x00', '\x05', // Length: 4
0x03, // Type: RST_STREAM '\x03', // Type: RST_STREAM
0x00, // Flags: none '\x00', // Flags: none
0x00, 0x00, 0x00, 0x01, // Stream: 1 '\x00', '\x00', '\x00', '\x01', // Stream: 1
0x00, 0x00, 0x00, 0x01, // Error: PROTOCOL_ERROR '\x00', '\x00', '\x00', '\x01', // Error: PROTOCOL_ERROR
0x00, // Too much '\x00', // Too much
}; };
Http2FrameHeader header(5, Http2FrameType::RST_STREAM, 0, 1); Http2FrameHeader header(5, Http2FrameType::RST_STREAM, 0, 1);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -881,12 +886,12 @@ TEST_F(Http2FrameDecoderTest, RstStreamTooLong) { ...@@ -881,12 +886,12 @@ TEST_F(Http2FrameDecoderTest, RstStreamTooLong) {
TEST_F(Http2FrameDecoderTest, SettingsAckTooLong) { TEST_F(Http2FrameDecoderTest, SettingsAckTooLong) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x06, // Length: 6 '\x00', '\x00', '\x06', // Length: 6
0x04, // Type: SETTINGS '\x04', // Type: SETTINGS
0x01, // Flags: ACK '\x01', // Flags: ACK
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
0x00, 0x00, // Extra '\x00', '\x00', // Extra
0x00, 0x00, 0x00, 0x00, // Extra '\x00', '\x00', '\x00', '\x00', // Extra
}; };
Http2FrameHeader header(6, Http2FrameType::SETTINGS, Http2FrameFlag::ACK, 0); Http2FrameHeader header(6, Http2FrameType::SETTINGS, Http2FrameFlag::ACK, 0);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -894,13 +899,13 @@ TEST_F(Http2FrameDecoderTest, SettingsAckTooLong) { ...@@ -894,13 +899,13 @@ TEST_F(Http2FrameDecoderTest, SettingsAckTooLong) {
TEST_F(Http2FrameDecoderTest, PingAckTooLong) { TEST_F(Http2FrameDecoderTest, PingAckTooLong) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x09, // Length: 8 '\x00', '\x00', '\x09', // Length: 8
0x06, // Type: PING '\x06', // Type: PING
0xffu, // Flags: ACK | 0xfe '\xff', // Flags: ACK | 0xfe
0x00, 0x00, 0x00, 0x00, // Stream: 0 '\x00', '\x00', '\x00', '\x00', // Stream: 0
's', 'o', 'm', 'e', // "some" 's', 'o', 'm', 'e', // "some"
'd', 'a', 't', 'a', // "data" 'd', 'a', 't', 'a', // "data"
0x00, // Too much '\x00', // Too much
}; };
Http2FrameHeader header(9, Http2FrameType::PING, Http2FrameFlag::ACK, 0); Http2FrameHeader header(9, Http2FrameType::PING, Http2FrameFlag::ACK, 0);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
...@@ -908,12 +913,12 @@ TEST_F(Http2FrameDecoderTest, PingAckTooLong) { ...@@ -908,12 +913,12 @@ TEST_F(Http2FrameDecoderTest, PingAckTooLong) {
TEST_F(Http2FrameDecoderTest, WindowUpdateTooLong) { TEST_F(Http2FrameDecoderTest, WindowUpdateTooLong) {
const char kFrameData[] = { const char kFrameData[] = {
0x00, 0x00, 0x05, // Length: 5 '\x00', '\x00', '\x05', // Length: 5
0x08, // Type: WINDOW_UPDATE '\x08', // Type: WINDOW_UPDATE
0x0f, // Flags: 0xff (no valid flags) '\x0f', // Flags: 0xff (no valid flags)
0x00, 0x00, 0x00, 0x01, // Stream: 1 '\x00', '\x00', '\x00', '\x01', // Stream: 1
0x80u, 0x00, 0x04, 0x00, // Incr: 1024 (plus R bit) '\x80', '\x00', '\x04', '\x00', // Incr: 1024 (plus R bit)
0x00, // Too much '\x00', // Too much
}; };
Http2FrameHeader header(5, Http2FrameType::WINDOW_UPDATE, 0, 1); Http2FrameHeader header(5, Http2FrameType::WINDOW_UPDATE, 0, 1);
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header)); EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
......
...@@ -56,7 +56,7 @@ class HpackEntryDecoderTest : public RandomDecoderTest { ...@@ -56,7 +56,7 @@ class HpackEntryDecoderTest : public RandomDecoderTest {
TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) { TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) {
{ {
const char input[] = {0x82u}; // == Index 2 == const char input[] = {'\x82'}; // == Index 2 ==
DecodeBuffer b(input); DecodeBuffer b(input);
auto do_check = [this]() { auto do_check = [this]() {
VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(2)); VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(2));
...@@ -67,7 +67,7 @@ TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) { ...@@ -67,7 +67,7 @@ TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) {
} }
collector_.Clear(); collector_.Clear();
{ {
const char input[] = {0xfeu}; // == Index 126 == const char input[] = {'\xfe'}; // == Index 126 ==
DecodeBuffer b(input); DecodeBuffer b(input);
auto do_check = [this]() { auto do_check = [this]() {
VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(126)); VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(126));
...@@ -78,7 +78,7 @@ TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) { ...@@ -78,7 +78,7 @@ TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) {
} }
collector_.Clear(); collector_.Clear();
{ {
const char input[] = {0xffu, 0x00}; // == Index 127 == const char input[] = {'\xff', '\x00'}; // == Index 127 ==
DecodeBuffer b(input); DecodeBuffer b(input);
auto do_check = [this]() { auto do_check = [this]() {
VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(127)); VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(127));
......
...@@ -81,7 +81,7 @@ class HpackStringDecoderTest : public RandomDecoderTest { ...@@ -81,7 +81,7 @@ class HpackStringDecoderTest : public RandomDecoderTest {
TEST_F(HpackStringDecoderTest, DecodeEmptyString) { TEST_F(HpackStringDecoderTest, DecodeEmptyString) {
{ {
Validator validator = ValidateDoneAndEmpty(MakeValidator("", kCompressed)); Validator validator = ValidateDoneAndEmpty(MakeValidator("", kCompressed));
const char kData[] = {0x80u}; const char kData[] = {'\x80'};
DecodeBuffer b(kData); DecodeBuffer b(kData);
EXPECT_TRUE( EXPECT_TRUE(
DecodeAndValidateSeveralWays(&b, kMayReturnZeroOnFirst, validator)); DecodeAndValidateSeveralWays(&b, kMayReturnZeroOnFirst, validator));
...@@ -90,7 +90,7 @@ TEST_F(HpackStringDecoderTest, DecodeEmptyString) { ...@@ -90,7 +90,7 @@ TEST_F(HpackStringDecoderTest, DecodeEmptyString) {
// Make sure it stops after decoding the empty string. // Make sure it stops after decoding the empty string.
Validator validator = Validator validator =
ValidateDoneAndOffset(1, MakeValidator("", kUncompressed)); ValidateDoneAndOffset(1, MakeValidator("", kUncompressed));
const char kData[] = {0x00, 0xffu}; const char kData[] = {'\x00', '\xff'};
DecodeBuffer b(kData); DecodeBuffer b(kData);
EXPECT_EQ(2u, b.Remaining()); EXPECT_EQ(2u, b.Remaining());
EXPECT_TRUE( EXPECT_TRUE(
......
...@@ -115,9 +115,9 @@ TEST(HpackBlockBuilderTest, ExamplesFromSpecC4) { ...@@ -115,9 +115,9 @@ TEST(HpackBlockBuilderTest, ExamplesFromSpecC4) {
b.AppendIndexedHeader(kStaticTableMethodGET); b.AppendIndexedHeader(kStaticTableMethodGET);
b.AppendIndexedHeader(kStaticTableSchemeHttp); b.AppendIndexedHeader(kStaticTableSchemeHttp);
b.AppendIndexedHeader(kStaticTablePathSlash); b.AppendIndexedHeader(kStaticTablePathSlash);
const char kHuffmanWwwExampleCom[] = {0xf1u, 0xe3u, 0xc2u, 0xe5u, const char kHuffmanWwwExampleCom[] = {'\xf1', '\xe3', '\xc2', '\xe5',
0xf2u, 0x3au, 0x6bu, 0xa0u, '\xf2', '\x3a', '\x6b', '\xa0',
0xabu, 0x90u, 0xf4u, 0xffu}; '\xab', '\x90', '\xf4', '\xff'};
b.AppendNameIndexAndLiteralValue( b.AppendNameIndexAndLiteralValue(
HpackEntryType::kIndexedLiteralHeader, 1, kCompressed, HpackEntryType::kIndexedLiteralHeader, 1, kCompressed,
Http2StringPiece(kHuffmanWwwExampleCom, sizeof kHuffmanWwwExampleCom)); Http2StringPiece(kHuffmanWwwExampleCom, sizeof kHuffmanWwwExampleCom));
...@@ -139,7 +139,7 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) { ...@@ -139,7 +139,7 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) {
b.AppendDynamicTableSizeUpdate(0); b.AppendDynamicTableSizeUpdate(0);
EXPECT_EQ(1u, b.size()); EXPECT_EQ(1u, b.size());
const char kData[] = {0x20}; const char kData[] = {'\x20'};
Http2StringPiece expected(kData, sizeof kData); Http2StringPiece expected(kData, sizeof kData);
EXPECT_EQ(expected, b.buffer()); EXPECT_EQ(expected, b.buffer());
} }
...@@ -148,7 +148,7 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) { ...@@ -148,7 +148,7 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) {
b.AppendDynamicTableSizeUpdate(4096); // The default size. b.AppendDynamicTableSizeUpdate(4096); // The default size.
EXPECT_EQ(3u, b.size()); EXPECT_EQ(3u, b.size());
const char kData[] = {0x3f, 0xe1u, 0x1f}; const char kData[] = {'\x3f', '\xe1', '\x1f'};
Http2StringPiece expected(kData, sizeof kData); Http2StringPiece expected(kData, sizeof kData);
EXPECT_EQ(expected, b.buffer()); EXPECT_EQ(expected, b.buffer());
} }
...@@ -157,7 +157,8 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) { ...@@ -157,7 +157,8 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) {
b.AppendDynamicTableSizeUpdate(1000000000000); // A very large value. b.AppendDynamicTableSizeUpdate(1000000000000); // A very large value.
EXPECT_EQ(7u, b.size()); EXPECT_EQ(7u, b.size());
const char kData[] = {0x3fu, 0xe1u, 0x9fu, 0x94u, 0xa5u, 0x8du, 0x1du}; const char kData[] = {'\x3f', '\xe1', '\x9f', '\x94',
'\xa5', '\x8d', '\x1d'};
Http2StringPiece expected(kData, sizeof kData); Http2StringPiece expected(kData, sizeof kData);
EXPECT_EQ(expected, b.buffer()); EXPECT_EQ(expected, b.buffer());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment