Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 349293010: Deprecate HTTP/2 PAD_HIGH field and enforce max padding size to 256 octets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nullptr => NULL. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_framer_test.cc
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc
index 9e00bb40d0ccfb01c897d520edc7be891eb56c32..57626afe1d23e5e5c375b94e13f598941ab74fd5 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -1576,13 +1576,12 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
};
const unsigned char kV4FrameData[] = {
- 0x01, 0x0b, 0x00, 0x18, // Length = 267. PAD_HIGH and PAD_LOW set.
+ 0x00, 0xfd, 0x00, 0x08, // Length = 253. PADDED set.
0x00, 0x00, 0x00, 0x01,
- 0x01, 0x04, // Pad Low and Pad High fields.
+ 0xf7, // Pad length field.
'h', 'e', 'l', 'l', // Data
'o',
- // Padding of 260 zeros (so both PAD_HIGH and PAD_LOW fields are used).
- '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ // Padding of 247 zeros.
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
@@ -1606,9 +1605,9 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
const char bytes[] = "hello";
SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes)));
- // 260 zeros and the pad low/high fields make the overall padding to be 262
+ // 247 zeros and the pad length field make the overall padding to be 248
// bytes.
- data_ir.set_padding_len(262);
+ data_ir.set_padding_len(248);
scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
if (IsSpdy4()) {
CompareFrame(
@@ -1637,9 +1636,9 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
};
const unsigned char kV4FrameData[] = {
- 0x00, 0x0d, 0x00, 0x08, // Length = 13. PAD_LOW set.
+ 0x00, 0x0d, 0x00, 0x08, // Length = 13. PADDED set.
0x00, 0x00, 0x00, 0x01,
- 0x07, // Pad Low field.
+ 0x07, // Pad length field.
'h', 'e', 'l', 'l', // Data
'o',
'0', '0', '0', '0', // Padding
@@ -1648,7 +1647,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
const char bytes[] = "hello";
SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes)));
- // 7 zeros and the pad low field make the overall padding to be 8 bytes.
+ // 7 zeros and the pad length field make the overall padding to be 8 bytes.
data_ir.set_padding_len(8);
scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
if (IsSpdy4()) {
@@ -1671,16 +1670,16 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
};
const unsigned char kV4FrameData[] = {
- 0x00, 0x06, 0x00, 0x08, // Length = 6. PAD_LOW set.
+ 0x00, 0x06, 0x00, 0x08, // Length = 6. PADDED set.
0x00, 0x00, 0x00, 0x01,
- 0x00, // Pad Low field.
+ 0x00, // Pad length field.
'h', 'e', 'l', 'l', // Data
'o',
};
const char bytes[] = "hello";
SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes)));
- // The pad low field itself is used for the 1-byte padding and no padding
+ // The pad length field itself is used for the 1-byte padding and no padding
// payload is needed.
data_ir.set_padding_len(1);
scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
@@ -3576,13 +3575,12 @@ TEST_P(SpdyFramerTest, ProcessSettingsAckFrame) {
EXPECT_EQ(1, visitor.settings_ack_received_);
}
-
TEST_P(SpdyFramerTest, ProcessDataFrameWithPadding) {
if (spdy_version_ <= SPDY3) {
return;
}
- const int kPaddingLen = 512; // So we get two bytes for padding length field.
+ const int kPaddingLen = 119;
const char data_payload[] = "hello";
testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
@@ -3605,26 +3603,20 @@ TEST_P(SpdyFramerTest, ProcessDataFrameWithPadding) {
CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR);
bytes_consumed += 8;
- // Send the first byte of the padding length field.
- CHECK_EQ(1u, framer.ProcessInput(frame->data() + bytes_consumed, 1));
- CHECK_EQ(framer.state(), SpdyFramer::SPDY_READ_PADDING_LENGTH);
- CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR);
- bytes_consumed += 1;
-
- // Send the second byte of the padding length field.
+ // Send the padding length field.
CHECK_EQ(1u, framer.ProcessInput(frame->data() + bytes_consumed, 1));
CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME);
CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR);
bytes_consumed += 1;
- // Send the first two bytes of the data payload.
+ // Send the first two bytes of the data payload, i.e., "he".
EXPECT_CALL(visitor, OnStreamFrameData(1, _, 2, false));
CHECK_EQ(2u, framer.ProcessInput(frame->data() + bytes_consumed, 2));
CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME);
CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR);
bytes_consumed += 2;
- // Send the rest three bytes of the data payload.
+ // Send the rest three bytes of the data payload, i.e., "llo".
EXPECT_CALL(visitor, OnStreamFrameData(1, _, 3, false));
CHECK_EQ(3u, framer.ProcessInput(frame->data() + bytes_consumed, 3));
CHECK_EQ(framer.state(), SpdyFramer::SPDY_CONSUME_PADDING);
@@ -3639,8 +3631,8 @@ TEST_P(SpdyFramerTest, ProcessDataFrameWithPadding) {
bytes_consumed += 100;
// Send rest of the padding payload.
- EXPECT_CALL(visitor, OnStreamFrameData(1, NULL, 410, false));
- CHECK_EQ(410u, framer.ProcessInput(frame->data() + bytes_consumed, 410));
+ EXPECT_CALL(visitor, OnStreamFrameData(1, NULL, 18, false));
+ CHECK_EQ(18u, framer.ProcessInput(frame->data() + bytes_consumed, 18));
CHECK_EQ(framer.state(), SpdyFramer::SPDY_RESET);
CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR);
}
@@ -3779,7 +3771,7 @@ TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) {
}
const unsigned char kInput[] = {
- 0x00, 0x14, 0x01, 0x08, // HEADERS: PAD_LOW
+ 0x00, 0x14, 0x01, 0x08, // HEADERS: PADDED
0x00, 0x00, 0x00, 0x01, // Stream 1
0x03, // Padding of 3.
0x00, 0x06, 0x63, 0x6f,
@@ -3871,10 +3863,10 @@ TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) {
}
const unsigned char kInput[] = {
- 0x00, 0x18, 0x05, 0x18, // PUSH_PROMISE: PAD_LOW & PAD_HIGH
+ 0x00, 0x17, 0x05, 0x08, // PUSH_PROMISE: PADDED
0x00, 0x00, 0x00, 0x01, // Stream 1
0x00, 0x00, 0x00, 0x2A, // Promised stream 42
- 0x00, 0x02, // Padding of 2.
+ 0x02, // Padding of 2.
0x00, 0x06, 0x63, 0x6f,
0x6f, 0x6b, 0x69, 0x65,
0x07, 0x66, 0x6f, 0x6f,
@@ -4381,7 +4373,7 @@ TEST_P(SpdyFramerTest, DataFrameFlagsV4) {
}
uint8 valid_data_flags = DATA_FLAG_FIN | DATA_FLAG_END_SEGMENT |
- DATA_FLAG_PAD_LOW | DATA_FLAG_PAD_HIGH;
+ DATA_FLAG_PADDED;
for (int flags = 0; flags < 256; ++flags) {
SCOPED_TRACE(testing::Message() << "Flags " << flags);
@@ -4398,8 +4390,8 @@ TEST_P(SpdyFramerTest, DataFrameFlagsV4) {
EXPECT_CALL(visitor, OnError(_));
} else {
EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN));
- if ((flags & DATA_FLAG_PAD_LOW) || (flags & DATA_FLAG_PAD_HIGH)) {
- // Expect Error since we don't set pad_high and pad_low in payload.
+ if (flags & DATA_FLAG_PADDED) {
+ // Expect Error since we don't set padded in payload.
EXPECT_CALL(visitor, OnError(_));
} else {
EXPECT_CALL(visitor, OnStreamFrameData(_, _, 5, false));
@@ -4410,8 +4402,7 @@ TEST_P(SpdyFramerTest, DataFrameFlagsV4) {
}
framer.ProcessInput(frame->data(), frame->size());
- if ((flags & ~valid_data_flags) || (flags & DATA_FLAG_PAD_LOW) ||
- (flags & DATA_FLAG_PAD_HIGH)) {
+ if ((flags & ~valid_data_flags) || (flags & DATA_FLAG_PADDED)) {
EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
EXPECT_EQ(SpdyFramer::SPDY_INVALID_DATA_FRAME_FLAGS,
framer.error_code())
@@ -4686,8 +4677,7 @@ TEST_P(SpdyFramerTest, HeadersFrameFlags) {
if (IsSpdy4()) {
// TODO(jgraettinger): Add padding to SpdyHeadersIR,
// and implement framing.
- set_flags &= ~HEADERS_FLAG_PAD_LOW;
- set_flags &= ~HEADERS_FLAG_PAD_HIGH;
+ set_flags &= ~HEADERS_FLAG_PADDED;
}
SetFrameFlags(frame.get(), set_flags, spdy_version_);
@@ -4696,8 +4686,7 @@ TEST_P(SpdyFramerTest, HeadersFrameFlags) {
} else if (IsSpdy4() && flags & ~(CONTROL_FLAG_FIN |
HEADERS_FLAG_END_HEADERS |
HEADERS_FLAG_END_SEGMENT |
- HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH |
+ HEADERS_FLAG_PADDED |
HEADERS_FLAG_PRIORITY)) {
EXPECT_CALL(visitor, OnError(_));
} else {
@@ -4733,8 +4722,7 @@ TEST_P(SpdyFramerTest, HeadersFrameFlags) {
} else if (IsSpdy4() && flags & ~(CONTROL_FLAG_FIN |
HEADERS_FLAG_END_HEADERS |
HEADERS_FLAG_END_SEGMENT |
- HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH |
+ HEADERS_FLAG_PADDED |
HEADERS_FLAG_PRIORITY)) {
EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS,
@@ -4841,12 +4829,10 @@ TEST_P(SpdyFramerTest, PushPromiseFrameFlags) {
framer.SerializePushPromise(push_promise));
// TODO(jgraettinger): Add padding to SpdyPushPromiseIR,
// and implement framing.
- int set_flags = flags & ~HEADERS_FLAG_PAD_LOW & ~HEADERS_FLAG_PAD_HIGH;
+ int set_flags = flags & ~HEADERS_FLAG_PADDED;
SetFrameFlags(frame.get(), set_flags, spdy_version_);
- if (flags & ~(PUSH_PROMISE_FLAG_END_PUSH_PROMISE |
- HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH)) {
+ if (flags & ~(PUSH_PROMISE_FLAG_END_PUSH_PROMISE | HEADERS_FLAG_PADDED)) {
EXPECT_CALL(visitor, OnError(_));
} else {
EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(42, PUSH_PROMISE, _));
@@ -4857,9 +4843,7 @@ TEST_P(SpdyFramerTest, PushPromiseFrameFlags) {
}
framer.ProcessInput(frame->data(), frame->size());
- if (flags & ~(PUSH_PROMISE_FLAG_END_PUSH_PROMISE |
- HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH)) {
+ if (flags & ~(PUSH_PROMISE_FLAG_END_PUSH_PROMISE | HEADERS_FLAG_PADDED)) {
EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS,
framer.error_code())
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698