OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 SpdyFramer* framer, const SpdyFrameType& frame) { | 56 SpdyFramer* framer, const SpdyFrameType& frame) { |
57 DecompressionVisitor visitor(framer->protocol_version()); | 57 DecompressionVisitor visitor(framer->protocol_version()); |
58 framer->set_visitor(&visitor); | 58 framer->set_visitor(&visitor); |
59 CHECK_EQ(frame.size(), framer->ProcessInput(frame.data(), frame.size())); | 59 CHECK_EQ(frame.size(), framer->ProcessInput(frame.data(), frame.size())); |
60 CHECK_EQ(SpdyFramer::SPDY_RESET, framer->state()); | 60 CHECK_EQ(SpdyFramer::SPDY_RESET, framer->state()); |
61 framer->set_visitor(NULL); | 61 framer->set_visitor(NULL); |
62 | 62 |
63 char* buffer = visitor.ReleaseBuffer(); | 63 char* buffer = visitor.ReleaseBuffer(); |
64 CHECK(buffer != NULL); | 64 CHECK(buffer != NULL); |
65 SpdyFrame* decompressed_frame = new SpdyFrame(buffer, visitor.size(), true); | 65 SpdyFrame* decompressed_frame = new SpdyFrame(buffer, visitor.size(), true); |
66 if (framer->protocol_version() == 4) { | 66 SetFrameLength(decompressed_frame, |
67 SetFrameLength(decompressed_frame, | 67 visitor.size() - framer->GetControlFrameHeaderSize(), |
68 visitor.size(), | 68 framer->protocol_version()); |
69 framer->protocol_version()); | |
70 } else { | |
71 SetFrameLength(decompressed_frame, | |
72 visitor.size() - framer->GetControlFrameHeaderSize(), | |
73 framer->protocol_version()); | |
74 } | |
75 return decompressed_frame; | 69 return decompressed_frame; |
76 } | 70 } |
77 | 71 |
78 class DecompressionVisitor : public SpdyFramerVisitorInterface { | 72 class DecompressionVisitor : public SpdyFramerVisitorInterface { |
79 public: | 73 public: |
80 explicit DecompressionVisitor(SpdyMajorVersion version) | 74 explicit DecompressionVisitor(SpdyMajorVersion version) |
81 : version_(version), size_(0), finished_(false) {} | 75 : version_(version), size_(0), finished_(false) {} |
82 | 76 |
83 void ResetBuffer() { | 77 void ResetBuffer() { |
84 CHECK(buffer_.get() == NULL); | 78 CHECK(buffer_.get() == NULL); |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 | 1040 |
1047 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 | 1041 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 |
1048 0x00, 0x00, 0x00, 0x08, | 1042 0x00, 0x00, 0x00, 0x08, |
1049 0x00, 0x00, 0x00, 0x03, | 1043 0x00, 0x00, 0x00, 0x03, |
1050 0x00, 0x00, 0x00, 0x00, | 1044 0x00, 0x00, 0x00, 0x00, |
1051 }; | 1045 }; |
1052 | 1046 |
1053 // SYN_STREAM doesn't exist in SPDY4, so instead we send | 1047 // SYN_STREAM doesn't exist in SPDY4, so instead we send |
1054 // HEADERS frames with PRIORITY and END_HEADERS set. | 1048 // HEADERS frames with PRIORITY and END_HEADERS set. |
1055 const unsigned char kV4Input[] = { | 1049 const unsigned char kV4Input[] = { |
1056 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1050 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1057 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1051 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1058 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1052 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1059 0x82, // :method: GET | 1053 0x82, // :method: GET |
1060 | 1054 |
1061 0x00, 0x09, 0x08, 0x04, // HEADERS: END_HEADERS | 1055 0x00, 0x01, 0x08, 0x04, // HEADERS: END_HEADERS |
1062 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1056 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1063 0x8c, // :status: 200 | 1057 0x8c, // :status: 200 |
1064 | 1058 |
1065 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1 | 1059 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 |
1066 0x00, 0x00, 0x00, 0x01, | 1060 0x00, 0x00, 0x00, 0x01, |
1067 0xde, 0xad, 0xbe, 0xef, | 1061 0xde, 0xad, 0xbe, 0xef, |
1068 0xde, 0xad, 0xbe, 0xef, | 1062 0xde, 0xad, 0xbe, 0xef, |
1069 0xde, 0xad, 0xbe, 0xef, | 1063 0xde, 0xad, 0xbe, 0xef, |
1070 | 1064 |
1071 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1065 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1072 0x00, 0x00, 0x00, 0x03, // Stream 3 | 1066 0x00, 0x00, 0x00, 0x03, // Stream 3 |
1073 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1067 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1074 0x82, // :method: GET | 1068 0x82, // :method: GET |
1075 | 1069 |
1076 0x00, 0x10, 0x00, 0x00, // DATA on Stream #3 | 1070 0x00, 0x08, 0x00, 0x00, // DATA on Stream #3 |
1077 0x00, 0x00, 0x00, 0x03, | 1071 0x00, 0x00, 0x00, 0x03, |
1078 0xde, 0xad, 0xbe, 0xef, | 1072 0xde, 0xad, 0xbe, 0xef, |
1079 0xde, 0xad, 0xbe, 0xef, | 1073 0xde, 0xad, 0xbe, 0xef, |
1080 | 1074 |
1081 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 | 1075 0x00, 0x04, 0x00, 0x00, // DATA on Stream #1 |
1082 0x00, 0x00, 0x00, 0x01, | 1076 0x00, 0x00, 0x00, 0x01, |
1083 0xde, 0xad, 0xbe, 0xef, | 1077 0xde, 0xad, 0xbe, 0xef, |
1084 | 1078 |
1085 0x00, 0x0c, 0x03, 0x00, // RST_STREAM on Stream #1 | 1079 0x00, 0x04, 0x03, 0x00, // RST_STREAM on Stream #1 |
1086 0x00, 0x00, 0x00, 0x01, | 1080 0x00, 0x00, 0x00, 0x01, |
1087 0x00, 0x00, 0x00, 0x00, | 1081 0x00, 0x00, 0x00, 0x00, |
1088 | 1082 |
1089 0x00, 0x08, 0x00, 0x00, // DATA on Stream #3 | 1083 0x00, 0x00, 0x00, 0x00, // DATA on Stream #3 |
1090 0x00, 0x00, 0x00, 0x03, | 1084 0x00, 0x00, 0x00, 0x03, |
1091 | 1085 |
1092 0x00, 0x17, 0x03, 0x00, // RST_STREAM on Stream #3 | 1086 0x00, 0x0f, 0x03, 0x00, // RST_STREAM on Stream #3 |
1093 0x00, 0x00, 0x00, 0x03, | 1087 0x00, 0x00, 0x00, 0x03, |
1094 0x00, 0x00, 0x00, 0x00, | 1088 0x00, 0x00, 0x00, 0x00, |
1095 0x52, 0x45, 0x53, 0x45, // opaque data | 1089 0x52, 0x45, 0x53, 0x45, // opaque data |
1096 0x54, 0x53, 0x54, 0x52, | 1090 0x54, 0x53, 0x54, 0x52, |
1097 0x45, 0x41, 0x4d, | 1091 0x45, 0x41, 0x4d, |
1098 }; | 1092 }; |
1099 | 1093 |
1100 TestSpdyVisitor visitor(spdy_version_); | 1094 TestSpdyVisitor visitor(spdy_version_); |
1101 if (IsSpdy2()) { | 1095 if (IsSpdy2()) { |
1102 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); | 1096 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 0xde, 0xad, 0xbe, 0xef, | 1175 0xde, 0xad, 0xbe, 0xef, |
1182 | 1176 |
1183 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF | 1177 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF |
1184 0x01, 0x00, 0x00, 0x04, | 1178 0x01, 0x00, 0x00, 0x04, |
1185 0xde, 0xad, 0xbe, 0xef, | 1179 0xde, 0xad, 0xbe, 0xef, |
1186 }; | 1180 }; |
1187 | 1181 |
1188 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send | 1182 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send |
1189 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. | 1183 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. |
1190 const unsigned char kV4Input[] = { | 1184 const unsigned char kV4Input[] = { |
1191 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1185 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1192 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1186 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1193 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1187 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1194 0x82, // :method: GET | 1188 0x82, // :method: GET |
1195 | 1189 |
1196 0x00, 0x09, 0x08, 0x04, // HEADERS: END_HEADERS | 1190 0x00, 0x01, 0x08, 0x04, // HEADERS: END_HEADERS |
1197 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1191 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1198 0x8c, // :status: 200 | 1192 0x8c, // :status: 200 |
1199 | 1193 |
1200 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1 | 1194 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 |
1201 0x00, 0x00, 0x00, 0x01, | 1195 0x00, 0x00, 0x00, 0x01, |
1202 0xde, 0xad, 0xbe, 0xef, | 1196 0xde, 0xad, 0xbe, 0xef, |
1203 0xde, 0xad, 0xbe, 0xef, | 1197 0xde, 0xad, 0xbe, 0xef, |
1204 0xde, 0xad, 0xbe, 0xef, | 1198 0xde, 0xad, 0xbe, 0xef, |
1205 | 1199 |
1206 0x00, 0x0c, 0x00, 0x01, // DATA on Stream #1, with FIN | 1200 0x00, 0x04, 0x00, 0x01, // DATA on Stream #1, with FIN |
1207 0x00, 0x00, 0x00, 0x01, | 1201 0x00, 0x00, 0x00, 0x01, |
1208 0xde, 0xad, 0xbe, 0xef, | 1202 0xde, 0xad, 0xbe, 0xef, |
1209 }; | 1203 }; |
1210 | 1204 |
1211 TestSpdyVisitor visitor(spdy_version_); | 1205 TestSpdyVisitor visitor(spdy_version_); |
1212 if (IsSpdy2()) { | 1206 if (IsSpdy2()) { |
1213 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); | 1207 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); |
1214 } else if (IsSpdy3()) { | 1208 } else if (IsSpdy3()) { |
1215 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); | 1209 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); |
1216 } else { | 1210 } else { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 0x00, 0x00, 0x00, 0x01, | 1261 0x00, 0x00, 0x00, 0x01, |
1268 0x00, 0x00, 0x00, 0x01, | 1262 0x00, 0x00, 0x00, 0x01, |
1269 0x00, 0x00, 0x00, 0x02, | 1263 0x00, 0x00, 0x00, 0x02, |
1270 'a', 'a', 0x00, 0x00, | 1264 'a', 'a', 0x00, 0x00, |
1271 0x00, 0x02, 'b', 'b', | 1265 0x00, 0x02, 'b', 'b', |
1272 }; | 1266 }; |
1273 | 1267 |
1274 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send | 1268 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send |
1275 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. | 1269 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. |
1276 const unsigned char kV4Input[] = { | 1270 const unsigned char kV4Input[] = { |
1277 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1271 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1278 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1272 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1279 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1273 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1280 0x82, // :method: GET | 1274 0x82, // :method: GET |
1281 | 1275 |
1282 0x00, 0x09, 0x08, 0x05, // HEADERS: FIN | END_HEADERS | 1276 0x00, 0x01, 0x08, 0x05, // HEADERS: FIN | END_HEADERS |
1283 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1277 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1284 0x8c, // :status: 200 | 1278 0x8c, // :status: 200 |
1285 }; | 1279 }; |
1286 | 1280 |
1287 TestSpdyVisitor visitor(spdy_version_); | 1281 TestSpdyVisitor visitor(spdy_version_); |
1288 if (IsSpdy2()) { | 1282 if (IsSpdy2()) { |
1289 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); | 1283 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); |
1290 } else if (IsSpdy3()) { | 1284 } else if (IsSpdy3()) { |
1291 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); | 1285 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); |
1292 } else { | 1286 } else { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 net::SpdyWindowUpdateIR(1, 0x12345678))); | 1469 net::SpdyWindowUpdateIR(1, 0x12345678))); |
1476 | 1470 |
1477 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; | 1471 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; |
1478 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1472 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1479 0x80, spdy_version_ch_, 0x00, 0x09, | 1473 0x80, spdy_version_ch_, 0x00, 0x09, |
1480 0x00, 0x00, 0x00, 0x08, | 1474 0x00, 0x00, 0x00, 0x08, |
1481 0x00, 0x00, 0x00, 0x01, | 1475 0x00, 0x00, 0x00, 0x01, |
1482 0x12, 0x34, 0x56, 0x78 | 1476 0x12, 0x34, 0x56, 0x78 |
1483 }; | 1477 }; |
1484 const unsigned char kV4FrameData[] = { | 1478 const unsigned char kV4FrameData[] = { |
1485 0x00, 0x0c, 0x09, 0x00, | 1479 0x00, 0x04, 0x09, 0x00, |
1486 0x00, 0x00, 0x00, 0x01, | 1480 0x00, 0x00, 0x00, 0x01, |
1487 0x12, 0x34, 0x56, 0x78 | 1481 0x12, 0x34, 0x56, 0x78 |
1488 }; | 1482 }; |
1489 | 1483 |
1490 if (IsSpdy4()) { | 1484 if (IsSpdy4()) { |
1491 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1485 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1492 } else { | 1486 } else { |
1493 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1487 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1494 } | 1488 } |
1495 } | 1489 } |
1496 | 1490 |
1497 TEST_P(SpdyFramerTest, CreateDataFrame) { | 1491 TEST_P(SpdyFramerTest, CreateDataFrame) { |
1498 SpdyFramer framer(spdy_version_); | 1492 SpdyFramer framer(spdy_version_); |
1499 | 1493 |
1500 { | 1494 { |
1501 const char kDescription[] = "'hello' data frame, no FIN"; | 1495 const char kDescription[] = "'hello' data frame, no FIN"; |
1502 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1496 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1503 0x00, 0x00, 0x00, 0x01, | 1497 0x00, 0x00, 0x00, 0x01, |
1504 0x00, 0x00, 0x00, 0x05, | 1498 0x00, 0x00, 0x00, 0x05, |
1505 'h', 'e', 'l', 'l', | 1499 'h', 'e', 'l', 'l', |
1506 'o' | 1500 'o' |
1507 }; | 1501 }; |
1508 const unsigned char kV4FrameData[] = { | 1502 const unsigned char kV4FrameData[] = { |
1509 0x00, 0x0d, 0x00, 0x00, | 1503 0x00, 0x05, 0x00, 0x00, |
1510 0x00, 0x00, 0x00, 0x01, | 1504 0x00, 0x00, 0x00, 0x01, |
1511 'h', 'e', 'l', 'l', | 1505 'h', 'e', 'l', 'l', |
1512 'o' | 1506 'o' |
1513 }; | 1507 }; |
1514 const char bytes[] = "hello"; | 1508 const char bytes[] = "hello"; |
1515 | 1509 |
1516 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); | 1510 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); |
1517 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1511 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1518 if (IsSpdy4()) { | 1512 if (IsSpdy4()) { |
1519 CompareFrame( | 1513 CompareFrame( |
(...skipping 17 matching lines...) Expand all Loading... |
1537 { | 1531 { |
1538 const char kDescription[] = "'hello' data frame with padding, no FIN"; | 1532 const char kDescription[] = "'hello' data frame with padding, no FIN"; |
1539 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1533 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1540 0x00, 0x00, 0x00, 0x01, | 1534 0x00, 0x00, 0x00, 0x01, |
1541 0x00, 0x00, 0x00, 0x05, | 1535 0x00, 0x00, 0x00, 0x05, |
1542 'h', 'e', 'l', 'l', | 1536 'h', 'e', 'l', 'l', |
1543 'o' | 1537 'o' |
1544 }; | 1538 }; |
1545 | 1539 |
1546 const unsigned char kV4FrameData[] = { | 1540 const unsigned char kV4FrameData[] = { |
1547 0x00, 0x15, 0x00, 0x10, // Length = 13. PAD_LOW set. | 1541 0x00, 0x0d, 0x00, 0x10, // Length = 13. PAD_LOW set. |
1548 0x00, 0x00, 0x00, 0x01, | 1542 0x00, 0x00, 0x00, 0x01, |
1549 0x07, // Pad Low field. | 1543 0x07, // Pad Low field. |
1550 'h', 'e', 'l', 'l', // Data | 1544 'h', 'e', 'l', 'l', // Data |
1551 'o', | 1545 'o', |
1552 '0', '0', '0', '0', // Padding | 1546 '0', '0', '0', '0', // Padding |
1553 '0', '0', '0' | 1547 '0', '0', '0' |
1554 }; | 1548 }; |
1555 const char bytes[] = "hello"; | 1549 const char bytes[] = "hello"; |
1556 | 1550 |
1557 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); | 1551 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); |
(...skipping 10 matching lines...) Expand all Loading... |
1568 } | 1562 } |
1569 | 1563 |
1570 { | 1564 { |
1571 const char kDescription[] = "Data frame with negative data byte, no FIN"; | 1565 const char kDescription[] = "Data frame with negative data byte, no FIN"; |
1572 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1566 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1573 0x00, 0x00, 0x00, 0x01, | 1567 0x00, 0x00, 0x00, 0x01, |
1574 0x00, 0x00, 0x00, 0x01, | 1568 0x00, 0x00, 0x00, 0x01, |
1575 0xff | 1569 0xff |
1576 }; | 1570 }; |
1577 const unsigned char kV4FrameData[] = { | 1571 const unsigned char kV4FrameData[] = { |
1578 0x00, 0x09, 0x00, 0x00, | 1572 0x00, 0x01, 0x00, 0x00, |
1579 0x00, 0x00, 0x00, 0x01, | 1573 0x00, 0x00, 0x00, 0x01, |
1580 0xff | 1574 0xff |
1581 }; | 1575 }; |
1582 net::SpdyDataIR data_ir(1, StringPiece("\xff", 1)); | 1576 net::SpdyDataIR data_ir(1, StringPiece("\xff", 1)); |
1583 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1577 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1584 if (IsSpdy4()) { | 1578 if (IsSpdy4()) { |
1585 CompareFrame( | 1579 CompareFrame( |
1586 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1580 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1587 } else { | 1581 } else { |
1588 CompareFrame( | 1582 CompareFrame( |
1589 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1583 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1590 } | 1584 } |
1591 } | 1585 } |
1592 | 1586 |
1593 { | 1587 { |
1594 const char kDescription[] = "'hello' data frame, with FIN"; | 1588 const char kDescription[] = "'hello' data frame, with FIN"; |
1595 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1589 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1596 0x00, 0x00, 0x00, 0x01, | 1590 0x00, 0x00, 0x00, 0x01, |
1597 0x01, 0x00, 0x00, 0x05, | 1591 0x01, 0x00, 0x00, 0x05, |
1598 'h', 'e', 'l', 'l', | 1592 'h', 'e', 'l', 'l', |
1599 'o' | 1593 'o' |
1600 }; | 1594 }; |
1601 const unsigned char kV4FrameData[] = { | 1595 const unsigned char kV4FrameData[] = { |
1602 0x00, 0x0d, 0x00, 0x01, | 1596 0x00, 0x05, 0x00, 0x01, |
1603 0x00, 0x00, 0x00, 0x01, | 1597 0x00, 0x00, 0x00, 0x01, |
1604 'h', 'e', 'l', 'l', | 1598 'h', 'e', 'l', 'l', |
1605 'o' | 1599 'o' |
1606 }; | 1600 }; |
1607 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); | 1601 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
1608 data_ir.set_fin(true); | 1602 data_ir.set_fin(true); |
1609 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1603 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1610 if (IsSpdy4()) { | 1604 if (IsSpdy4()) { |
1611 CompareFrame( | 1605 CompareFrame( |
1612 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1606 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1613 } else { | 1607 } else { |
1614 CompareFrame( | 1608 CompareFrame( |
1615 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1609 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1616 } | 1610 } |
1617 } | 1611 } |
1618 | 1612 |
1619 { | 1613 { |
1620 const char kDescription[] = "Empty data frame"; | 1614 const char kDescription[] = "Empty data frame"; |
1621 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1615 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1622 0x00, 0x00, 0x00, 0x01, | 1616 0x00, 0x00, 0x00, 0x01, |
1623 0x00, 0x00, 0x00, 0x00, | 1617 0x00, 0x00, 0x00, 0x00, |
1624 }; | 1618 }; |
1625 const unsigned char kV4FrameData[] = { | 1619 const unsigned char kV4FrameData[] = { |
1626 0x00, 0x08, 0x00, 0x00, | 1620 0x00, 0x00, 0x00, 0x00, |
1627 0x00, 0x00, 0x00, 0x01, | 1621 0x00, 0x00, 0x00, 0x01, |
1628 }; | 1622 }; |
1629 net::SpdyDataIR data_ir(1, StringPiece()); | 1623 net::SpdyDataIR data_ir(1, StringPiece()); |
1630 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1624 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1631 if (IsSpdy4()) { | 1625 if (IsSpdy4()) { |
1632 CompareFrame( | 1626 CompareFrame( |
1633 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1627 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1634 } else { | 1628 } else { |
1635 CompareFrame( | 1629 CompareFrame( |
1636 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1630 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1637 } | 1631 } |
1638 } | 1632 } |
1639 | 1633 |
1640 { | 1634 { |
1641 const char kDescription[] = "Data frame with max stream ID"; | 1635 const char kDescription[] = "Data frame with max stream ID"; |
1642 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1636 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1643 0x7f, 0xff, 0xff, 0xff, | 1637 0x7f, 0xff, 0xff, 0xff, |
1644 0x01, 0x00, 0x00, 0x05, | 1638 0x01, 0x00, 0x00, 0x05, |
1645 'h', 'e', 'l', 'l', | 1639 'h', 'e', 'l', 'l', |
1646 'o' | 1640 'o' |
1647 }; | 1641 }; |
1648 const unsigned char kV4FrameData[] = { | 1642 const unsigned char kV4FrameData[] = { |
1649 0x00, 0x0d, 0x00, 0x01, | 1643 0x00, 0x05, 0x00, 0x01, |
1650 0x7f, 0xff, 0xff, 0xff, | 1644 0x7f, 0xff, 0xff, 0xff, |
1651 'h', 'e', 'l', 'l', | 1645 'h', 'e', 'l', 'l', |
1652 'o' | 1646 'o' |
1653 }; | 1647 }; |
1654 net::SpdyDataIR data_ir(0x7fffffff, "hello"); | 1648 net::SpdyDataIR data_ir(0x7fffffff, "hello"); |
1655 data_ir.set_fin(true); | 1649 data_ir.set_fin(true); |
1656 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1650 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1657 if (IsSpdy4()) { | 1651 if (IsSpdy4()) { |
1658 CompareFrame( | 1652 CompareFrame( |
1659 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1653 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 0x00, 0x02, 0x00, 0x00, | 1710 0x00, 0x02, 0x00, 0x00, |
1717 0x00, 0x03, 'b', 'a', | 1711 0x00, 0x03, 'b', 'a', |
1718 'r', 0x00, 0x00, 0x00, | 1712 'r', 0x00, 0x00, 0x00, |
1719 0x03, 'f', 'o', 'o', | 1713 0x03, 'f', 'o', 'o', |
1720 0x00, 0x00, 0x00, 0x03, | 1714 0x00, 0x00, 0x00, 0x03, |
1721 'f', 'o', 'o', 0x00, | 1715 'f', 'o', 'o', 0x00, |
1722 0x00, 0x00, 0x03, 'b', | 1716 0x00, 0x00, 0x03, 'b', |
1723 'a', 'r' | 1717 'a', 'r' |
1724 }; | 1718 }; |
1725 const unsigned char kV4FrameData[] = { | 1719 const unsigned char kV4FrameData[] = { |
1726 0x00, 0x1e, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1720 0x00, 0x16, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1727 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1721 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1728 0x00, 0x00, 0x00, 0x07, // Priority 7 | 1722 0x00, 0x00, 0x00, 0x07, // Priority 7 |
1729 0x40, 0x03, 0x62, 0x61, // @.ba | 1723 0x40, 0x03, 0x62, 0x61, // @.ba |
1730 0x72, 0x03, 0x66, 0x6f, // r.fo | 1724 0x72, 0x03, 0x66, 0x6f, // r.fo |
1731 0x6f, 0x40, 0x03, 0x66, // o@.f | 1725 0x6f, 0x40, 0x03, 0x66, // o@.f |
1732 0x6f, 0x6f, 0x03, 0x62, // oo.b | 1726 0x6f, 0x6f, 0x03, 0x62, // oo.b |
1733 0x61, 0x72, // ar | 1727 0x61, 0x72, // ar |
1734 }; | 1728 }; |
1735 SpdySynStreamIR syn_stream(1); | 1729 SpdySynStreamIR syn_stream(1); |
1736 syn_stream.set_priority(framer.GetLowestPriority()); | 1730 syn_stream.set_priority(framer.GetLowestPriority()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 0x00, 0x00, 0x00, 0x00, | 1765 0x00, 0x00, 0x00, 0x00, |
1772 0x00, 0x02, 0x00, 0x00, | 1766 0x00, 0x02, 0x00, 0x00, |
1773 0x00, 0x00, 0x00, 0x00, | 1767 0x00, 0x00, 0x00, 0x00, |
1774 0x00, 0x03, 'f', 'o', | 1768 0x00, 0x03, 'f', 'o', |
1775 'o', 0x00, 0x00, 0x00, | 1769 'o', 0x00, 0x00, 0x00, |
1776 0x03, 'f', 'o', 'o', | 1770 0x03, 'f', 'o', 'o', |
1777 0x00, 0x00, 0x00, 0x03, | 1771 0x00, 0x00, 0x00, 0x03, |
1778 'b', 'a', 'r' | 1772 'b', 'a', 'r' |
1779 }; | 1773 }; |
1780 const unsigned char kV4FrameData[] = { | 1774 const unsigned char kV4FrameData[] = { |
1781 0x00, 0x1b, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS | 1775 0x00, 0x13, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS |
1782 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 1776 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
1783 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1777 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1784 0x40, 0x00, 0x03, 0x66, // @..f | 1778 0x40, 0x00, 0x03, 0x66, // @..f |
1785 0x6f, 0x6f, 0x40, 0x03, // oo@. | 1779 0x6f, 0x6f, 0x40, 0x03, // oo@. |
1786 0x66, 0x6f, 0x6f, 0x03, // foo. | 1780 0x66, 0x6f, 0x6f, 0x03, // foo. |
1787 0x62, 0x61, 0x72, // bar | 1781 0x62, 0x61, 0x72, // bar |
1788 }; | 1782 }; |
1789 SpdySynStreamIR syn_stream(0x7fffffff); | 1783 SpdySynStreamIR syn_stream(0x7fffffff); |
1790 syn_stream.set_associated_to_stream_id(0x7fffffff); | 1784 syn_stream.set_associated_to_stream_id(0x7fffffff); |
1791 syn_stream.set_priority(framer.GetHighestPriority()); | 1785 syn_stream.set_priority(framer.GetHighestPriority()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 kPri, 0x00, 0x00, 0x00, | 1822 kPri, 0x00, 0x00, 0x00, |
1829 0x00, 0x02, 0x00, 0x00, | 1823 0x00, 0x02, 0x00, 0x00, |
1830 0x00, 0x03, 'b', 'a', | 1824 0x00, 0x03, 'b', 'a', |
1831 'r', 0x00, 0x00, 0x00, | 1825 'r', 0x00, 0x00, 0x00, |
1832 0x03, 'f', 'o', 'o', | 1826 0x03, 'f', 'o', 'o', |
1833 0x00, 0x00, 0x00, 0x03, | 1827 0x00, 0x00, 0x00, 0x03, |
1834 'f', 'o', 'o', 0x00, | 1828 'f', 'o', 'o', 0x00, |
1835 0x00, 0x00, 0x00 | 1829 0x00, 0x00, 0x00 |
1836 }; | 1830 }; |
1837 const unsigned char kV4FrameData[] = { | 1831 const unsigned char kV4FrameData[] = { |
1838 0x00, 0x1b, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS | 1832 0x00, 0x13, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS |
1839 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 1833 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
1840 0x00, 0x00, 0x00, 0x01, // Priority 1 | 1834 0x00, 0x00, 0x00, 0x01, // Priority 1 |
1841 0x40, 0x03, 0x62, 0x61, // @.ba | 1835 0x40, 0x03, 0x62, 0x61, // @.ba |
1842 0x72, 0x03, 0x66, 0x6f, // r.fo | 1836 0x72, 0x03, 0x66, 0x6f, // r.fo |
1843 0x6f, 0x40, 0x03, 0x66, // o@.f | 1837 0x6f, 0x40, 0x03, 0x66, // o@.f |
1844 0x6f, 0x6f, 0x00, // oo. | 1838 0x6f, 0x6f, 0x00, // oo. |
1845 }; | 1839 }; |
1846 SpdySynStreamIR syn_stream(0x7fffffff); | 1840 SpdySynStreamIR syn_stream(0x7fffffff); |
1847 syn_stream.set_associated_to_stream_id(0x7fffffff); | 1841 syn_stream.set_associated_to_stream_id(0x7fffffff); |
1848 syn_stream.set_priority(1); | 1842 syn_stream.set_priority(1); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 0x00, 0x00, 0x00, 0x02, | 1943 0x00, 0x00, 0x00, 0x02, |
1950 0x00, 0x00, 0x00, 0x03, | 1944 0x00, 0x00, 0x00, 0x03, |
1951 'b', 'a', 'r', 0x00, | 1945 'b', 'a', 'r', 0x00, |
1952 0x00, 0x00, 0x03, 'f', | 1946 0x00, 0x00, 0x03, 'f', |
1953 'o', 'o', 0x00, 0x00, | 1947 'o', 'o', 0x00, 0x00, |
1954 0x00, 0x03, 'f', 'o', | 1948 0x00, 0x03, 'f', 'o', |
1955 'o', 0x00, 0x00, 0x00, | 1949 'o', 0x00, 0x00, 0x00, |
1956 0x03, 'b', 'a', 'r' | 1950 0x03, 'b', 'a', 'r' |
1957 }; | 1951 }; |
1958 const unsigned char kV4FrameData[] = { | 1952 const unsigned char kV4FrameData[] = { |
1959 0x00, 0x1a, 0x08, 0x04, // HEADER: END_HEADERS | 1953 0x00, 0x12, 0x08, 0x04, // HEADER: END_HEADERS |
1960 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1954 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1961 0x40, 0x03, 0x62, 0x61, // @.ba | 1955 0x40, 0x03, 0x62, 0x61, // @.ba |
1962 0x72, 0x03, 0x66, 0x6f, // r.fo | 1956 0x72, 0x03, 0x66, 0x6f, // r.fo |
1963 0x6f, 0x40, 0x03, 0x66, // o@.f | 1957 0x6f, 0x40, 0x03, 0x66, // o@.f |
1964 0x6f, 0x6f, 0x03, 0x62, // oo.b | 1958 0x6f, 0x6f, 0x03, 0x62, // oo.b |
1965 0x61, 0x72, // ar | 1959 0x61, 0x72, // ar |
1966 }; | 1960 }; |
1967 SpdySynReplyIR syn_reply(1); | 1961 SpdySynReplyIR syn_reply(1); |
1968 syn_reply.SetHeader("bar", "foo"); | 1962 syn_reply.SetHeader("bar", "foo"); |
1969 syn_reply.SetHeader("foo", "bar"); | 1963 syn_reply.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
1999 0x00, 0x00, 0x00, 0x02, | 1993 0x00, 0x00, 0x00, 0x02, |
2000 0x00, 0x00, 0x00, 0x00, | 1994 0x00, 0x00, 0x00, 0x00, |
2001 0x00, 0x00, 0x00, 0x03, | 1995 0x00, 0x00, 0x00, 0x03, |
2002 'f', 'o', 'o', 0x00, | 1996 'f', 'o', 'o', 0x00, |
2003 0x00, 0x00, 0x03, 'f', | 1997 0x00, 0x00, 0x03, 'f', |
2004 'o', 'o', 0x00, 0x00, | 1998 'o', 'o', 0x00, 0x00, |
2005 0x00, 0x03, 'b', 'a', | 1999 0x00, 0x03, 'b', 'a', |
2006 'r' | 2000 'r' |
2007 }; | 2001 }; |
2008 const unsigned char kV4FrameData[] = { | 2002 const unsigned char kV4FrameData[] = { |
2009 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 2003 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS |
2010 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 2004 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
2011 0x40, 0x00, 0x03, 0x66, // @..f | 2005 0x40, 0x00, 0x03, 0x66, // @..f |
2012 0x6f, 0x6f, 0x40, 0x03, // oo@. | 2006 0x6f, 0x6f, 0x40, 0x03, // oo@. |
2013 0x66, 0x6f, 0x6f, 0x03, // foo. | 2007 0x66, 0x6f, 0x6f, 0x03, // foo. |
2014 0x62, 0x61, 0x72, // bar | 2008 0x62, 0x61, 0x72, // bar |
2015 }; | 2009 }; |
2016 SpdySynReplyIR syn_reply(0x7fffffff); | 2010 SpdySynReplyIR syn_reply(0x7fffffff); |
2017 syn_reply.set_fin(true); | 2011 syn_reply.set_fin(true); |
2018 syn_reply.SetHeader("", "foo"); | 2012 syn_reply.SetHeader("", "foo"); |
2019 syn_reply.SetHeader("foo", "bar"); | 2013 syn_reply.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
2049 0x00, 0x00, 0x00, 0x02, | 2043 0x00, 0x00, 0x00, 0x02, |
2050 0x00, 0x00, 0x00, 0x03, | 2044 0x00, 0x00, 0x00, 0x03, |
2051 'b', 'a', 'r', 0x00, | 2045 'b', 'a', 'r', 0x00, |
2052 0x00, 0x00, 0x03, 'f', | 2046 0x00, 0x00, 0x03, 'f', |
2053 'o', 'o', 0x00, 0x00, | 2047 'o', 'o', 0x00, 0x00, |
2054 0x00, 0x03, 'f', 'o', | 2048 0x00, 0x03, 'f', 'o', |
2055 'o', 0x00, 0x00, 0x00, | 2049 'o', 0x00, 0x00, 0x00, |
2056 0x00 | 2050 0x00 |
2057 }; | 2051 }; |
2058 const unsigned char kV4FrameData[] = { | 2052 const unsigned char kV4FrameData[] = { |
2059 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 2053 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS |
2060 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 2054 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
2061 0x40, 0x03, 0x62, 0x61, // @.ba | 2055 0x40, 0x03, 0x62, 0x61, // @.ba |
2062 0x72, 0x03, 0x66, 0x6f, // r.fo | 2056 0x72, 0x03, 0x66, 0x6f, // r.fo |
2063 0x6f, 0x40, 0x03, 0x66, // o@.f | 2057 0x6f, 0x40, 0x03, 0x66, // o@.f |
2064 0x6f, 0x6f, 0x00, // oo. | 2058 0x6f, 0x6f, 0x00, // oo. |
2065 }; | 2059 }; |
2066 SpdySynReplyIR syn_reply(0x7fffffff); | 2060 SpdySynReplyIR syn_reply(0x7fffffff); |
2067 syn_reply.set_fin(true); | 2061 syn_reply.set_fin(true); |
2068 syn_reply.SetHeader("bar", "foo"); | 2062 syn_reply.SetHeader("bar", "foo"); |
2069 syn_reply.SetHeader("foo", ""); | 2063 syn_reply.SetHeader("foo", ""); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 | 2136 |
2143 { | 2137 { |
2144 const char kDescription[] = "RST_STREAM frame"; | 2138 const char kDescription[] = "RST_STREAM frame"; |
2145 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2139 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2146 0x80, spdy_version_ch_, 0x00, 0x03, | 2140 0x80, spdy_version_ch_, 0x00, 0x03, |
2147 0x00, 0x00, 0x00, 0x08, | 2141 0x00, 0x00, 0x00, 0x08, |
2148 0x00, 0x00, 0x00, 0x01, | 2142 0x00, 0x00, 0x00, 0x01, |
2149 0x00, 0x00, 0x00, 0x01, | 2143 0x00, 0x00, 0x00, 0x01, |
2150 }; | 2144 }; |
2151 const unsigned char kV4FrameData[] = { | 2145 const unsigned char kV4FrameData[] = { |
2152 0x00, 0x0f, 0x03, 0x00, | 2146 0x00, 0x07, 0x03, 0x00, |
2153 0x00, 0x00, 0x00, 0x01, | 2147 0x00, 0x00, 0x00, 0x01, |
2154 0x00, 0x00, 0x00, 0x01, | 2148 0x00, 0x00, 0x00, 0x01, |
2155 0x52, 0x53, 0x54 | 2149 0x52, 0x53, 0x54 |
2156 }; | 2150 }; |
2157 net::SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR, "RST"); | 2151 net::SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR, "RST"); |
2158 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2152 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
2159 if (IsSpdy4()) { | 2153 if (IsSpdy4()) { |
2160 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2154 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2161 } else { | 2155 } else { |
2162 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2156 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2163 } | 2157 } |
2164 } | 2158 } |
2165 | 2159 |
2166 { | 2160 { |
2167 const char kDescription[] = "RST_STREAM frame with max stream ID"; | 2161 const char kDescription[] = "RST_STREAM frame with max stream ID"; |
2168 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2162 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2169 0x80, spdy_version_ch_, 0x00, 0x03, | 2163 0x80, spdy_version_ch_, 0x00, 0x03, |
2170 0x00, 0x00, 0x00, 0x08, | 2164 0x00, 0x00, 0x00, 0x08, |
2171 0x7f, 0xff, 0xff, 0xff, | 2165 0x7f, 0xff, 0xff, 0xff, |
2172 0x00, 0x00, 0x00, 0x01, | 2166 0x00, 0x00, 0x00, 0x01, |
2173 }; | 2167 }; |
2174 const unsigned char kV4FrameData[] = { | 2168 const unsigned char kV4FrameData[] = { |
2175 0x00, 0x0c, 0x03, 0x00, | 2169 0x00, 0x04, 0x03, 0x00, |
2176 0x7f, 0xff, 0xff, 0xff, | 2170 0x7f, 0xff, 0xff, 0xff, |
2177 0x00, 0x00, 0x00, 0x01, | 2171 0x00, 0x00, 0x00, 0x01, |
2178 }; | 2172 }; |
2179 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, | 2173 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, |
2180 RST_STREAM_PROTOCOL_ERROR, | 2174 RST_STREAM_PROTOCOL_ERROR, |
2181 ""); | 2175 ""); |
2182 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2176 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
2183 if (IsSpdy4()) { | 2177 if (IsSpdy4()) { |
2184 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2178 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2185 } else { | 2179 } else { |
2186 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2180 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2187 } | 2181 } |
2188 } | 2182 } |
2189 | 2183 |
2190 { | 2184 { |
2191 const char kDescription[] = "RST_STREAM frame with max status code"; | 2185 const char kDescription[] = "RST_STREAM frame with max status code"; |
2192 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2186 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2193 0x80, spdy_version_ch_, 0x00, 0x03, | 2187 0x80, spdy_version_ch_, 0x00, 0x03, |
2194 0x00, 0x00, 0x00, 0x08, | 2188 0x00, 0x00, 0x00, 0x08, |
2195 0x7f, 0xff, 0xff, 0xff, | 2189 0x7f, 0xff, 0xff, 0xff, |
2196 0x00, 0x00, 0x00, 0x06, | 2190 0x00, 0x00, 0x00, 0x06, |
2197 }; | 2191 }; |
2198 const unsigned char kV4FrameData[] = { | 2192 const unsigned char kV4FrameData[] = { |
2199 0x00, 0x0c, 0x03, 0x00, | 2193 0x00, 0x04, 0x03, 0x00, |
2200 0x7f, 0xff, 0xff, 0xff, | 2194 0x7f, 0xff, 0xff, 0xff, |
2201 0x00, 0x00, 0x00, 0x06, | 2195 0x00, 0x00, 0x00, 0x06, |
2202 }; | 2196 }; |
2203 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, | 2197 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, |
2204 RST_STREAM_INTERNAL_ERROR, | 2198 RST_STREAM_INTERNAL_ERROR, |
2205 ""); | 2199 ""); |
2206 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2200 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
2207 if (IsSpdy4()) { | 2201 if (IsSpdy4()) { |
2208 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2202 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2209 } else { | 2203 } else { |
(...skipping 16 matching lines...) Expand all Loading... |
2226 0x0a, 0x0b, 0x0c, 0x0d, | 2220 0x0a, 0x0b, 0x0c, 0x0d, |
2227 }; | 2221 }; |
2228 const unsigned char kV3FrameData[] = { | 2222 const unsigned char kV3FrameData[] = { |
2229 0x80, spdy_version_ch_, 0x00, 0x04, | 2223 0x80, spdy_version_ch_, 0x00, 0x04, |
2230 0x00, 0x00, 0x00, 0x0c, | 2224 0x00, 0x00, 0x00, 0x0c, |
2231 0x00, 0x00, 0x00, 0x01, | 2225 0x00, 0x00, 0x00, 0x01, |
2232 0x01, 0x02, 0x03, 0x04, | 2226 0x01, 0x02, 0x03, 0x04, |
2233 0x0a, 0x0b, 0x0c, 0x0d, | 2227 0x0a, 0x0b, 0x0c, 0x0d, |
2234 }; | 2228 }; |
2235 const unsigned char kV4FrameData[] = { | 2229 const unsigned char kV4FrameData[] = { |
2236 0x00, 0x0d, 0x04, 0x00, | 2230 0x00, 0x05, 0x04, 0x00, |
2237 0x00, 0x00, 0x00, 0x00, | 2231 0x00, 0x00, 0x00, 0x00, |
2238 0x01, 0x0a, 0x0b, 0x0c, | 2232 0x01, 0x0a, 0x0b, 0x0c, |
2239 0x0d, | 2233 0x0d, |
2240 }; | 2234 }; |
2241 | 2235 |
2242 uint32 kValue = 0x0a0b0c0d; | 2236 uint32 kValue = 0x0a0b0c0d; |
2243 SpdySettingsIR settings_ir; | 2237 SpdySettingsIR settings_ir; |
2244 | 2238 |
2245 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x01); | 2239 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x01); |
2246 SpdySettingsIds kId = static_cast<SpdySettingsIds>(0x020304); | 2240 SpdySettingsIds kId = static_cast<SpdySettingsIds>(0x020304); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 0x00, 0x00, 0x00, 0x00, // 1st Setting | 2280 0x00, 0x00, 0x00, 0x00, // 1st Setting |
2287 0x00, 0x00, 0x00, 0x01, | 2281 0x00, 0x00, 0x00, 0x01, |
2288 0x01, 0x00, 0x00, 0x01, // 2nd Setting | 2282 0x01, 0x00, 0x00, 0x01, // 2nd Setting |
2289 0x00, 0x00, 0x00, 0x02, | 2283 0x00, 0x00, 0x00, 0x02, |
2290 0x02, 0x00, 0x00, 0x02, // 3rd Setting | 2284 0x02, 0x00, 0x00, 0x02, // 3rd Setting |
2291 0x00, 0x00, 0x00, 0x03, | 2285 0x00, 0x00, 0x00, 0x03, |
2292 0x03, 0x00, 0x00, 0x03, // 4th Setting | 2286 0x03, 0x00, 0x00, 0x03, // 4th Setting |
2293 0xff, 0x00, 0x00, 0x04, | 2287 0xff, 0x00, 0x00, 0x04, |
2294 }; | 2288 }; |
2295 const unsigned char kV4FrameData[] = { | 2289 const unsigned char kV4FrameData[] = { |
2296 0x00, 0x1c, 0x04, 0x00, | 2290 0x00, 0x14, 0x04, 0x00, |
2297 0x00, 0x00, 0x00, 0x00, | 2291 0x00, 0x00, 0x00, 0x00, |
2298 0x01, // 1st Setting | 2292 0x01, // 1st Setting |
2299 0x00, 0x00, 0x00, 0x01, | 2293 0x00, 0x00, 0x00, 0x01, |
2300 0x02, // 2nd Setting | 2294 0x02, // 2nd Setting |
2301 0x00, 0x00, 0x00, 0x02, | 2295 0x00, 0x00, 0x00, 0x02, |
2302 0x03, // 3rd Setting | 2296 0x03, // 3rd Setting |
2303 0x00, 0x00, 0x00, 0x03, | 2297 0x00, 0x00, 0x00, 0x03, |
2304 0x04, // 4th Setting | 2298 0x04, // 4th Setting |
2305 0xff, 0x00, 0x00, 0x04, | 2299 0xff, 0x00, 0x00, 0x04, |
2306 }; | 2300 }; |
(...skipping 27 matching lines...) Expand all Loading... |
2334 | 2328 |
2335 { | 2329 { |
2336 const char kDescription[] = "Empty SETTINGS frame"; | 2330 const char kDescription[] = "Empty SETTINGS frame"; |
2337 | 2331 |
2338 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2332 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2339 0x80, spdy_version_ch_, 0x00, 0x04, | 2333 0x80, spdy_version_ch_, 0x00, 0x04, |
2340 0x00, 0x00, 0x00, 0x04, | 2334 0x00, 0x00, 0x00, 0x04, |
2341 0x00, 0x00, 0x00, 0x00, | 2335 0x00, 0x00, 0x00, 0x00, |
2342 }; | 2336 }; |
2343 const unsigned char kV4FrameData[] = { | 2337 const unsigned char kV4FrameData[] = { |
2344 0x00, 0x08, 0x04, 0x00, | 2338 0x00, 0x00, 0x04, 0x00, |
2345 0x00, 0x00, 0x00, 0x00, | 2339 0x00, 0x00, 0x00, 0x00, |
2346 }; | 2340 }; |
2347 SpdySettingsIR settings_ir; | 2341 SpdySettingsIR settings_ir; |
2348 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); | 2342 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); |
2349 if (IsSpdy4()) { | 2343 if (IsSpdy4()) { |
2350 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2344 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2351 } else { | 2345 } else { |
2352 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2346 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2353 } | 2347 } |
2354 } | 2348 } |
2355 } | 2349 } |
2356 | 2350 |
2357 TEST_P(SpdyFramerTest, CreatePingFrame) { | 2351 TEST_P(SpdyFramerTest, CreatePingFrame) { |
2358 SpdyFramer framer(spdy_version_); | 2352 SpdyFramer framer(spdy_version_); |
2359 | 2353 |
2360 { | 2354 { |
2361 const char kDescription[] = "PING frame"; | 2355 const char kDescription[] = "PING frame"; |
2362 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2356 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2363 0x80, spdy_version_ch_, 0x00, 0x06, | 2357 0x80, spdy_version_ch_, 0x00, 0x06, |
2364 0x00, 0x00, 0x00, 0x04, | 2358 0x00, 0x00, 0x00, 0x04, |
2365 0x12, 0x34, 0x56, 0x78, | 2359 0x12, 0x34, 0x56, 0x78, |
2366 }; | 2360 }; |
2367 const unsigned char kV4FrameData[] = { | 2361 const unsigned char kV4FrameData[] = { |
2368 0x00, 0x10, 0x06, 0x00, | 2362 0x00, 0x08, 0x06, 0x00, |
2369 0x00, 0x00, 0x00, 0x00, | 2363 0x00, 0x00, 0x00, 0x00, |
2370 0x12, 0x34, 0x56, 0x78, | 2364 0x12, 0x34, 0x56, 0x78, |
2371 0x9a, 0xbc, 0xde, 0xff, | 2365 0x9a, 0xbc, 0xde, 0xff, |
2372 }; | 2366 }; |
2373 const unsigned char kV4FrameDataWithAck[] = { | 2367 const unsigned char kV4FrameDataWithAck[] = { |
2374 0x00, 0x10, 0x06, 0x01, | 2368 0x00, 0x08, 0x06, 0x01, |
2375 0x00, 0x00, 0x00, 0x00, | 2369 0x00, 0x00, 0x00, 0x00, |
2376 0x12, 0x34, 0x56, 0x78, | 2370 0x12, 0x34, 0x56, 0x78, |
2377 0x9a, 0xbc, 0xde, 0xff, | 2371 0x9a, 0xbc, 0xde, 0xff, |
2378 }; | 2372 }; |
2379 scoped_ptr<SpdyFrame> frame; | 2373 scoped_ptr<SpdyFrame> frame; |
2380 if (IsSpdy4()) { | 2374 if (IsSpdy4()) { |
2381 const SpdyPingId kPingId = 0x123456789abcdeffULL; | 2375 const SpdyPingId kPingId = 0x123456789abcdeffULL; |
2382 SpdyPingIR ping_ir(kPingId); | 2376 SpdyPingIR ping_ir(kPingId); |
2383 // Tests SpdyPingIR when the ping is not an ack. | 2377 // Tests SpdyPingIR when the ping is not an ack. |
2384 ASSERT_FALSE(ping_ir.is_ack()); | 2378 ASSERT_FALSE(ping_ir.is_ack()); |
(...skipping 23 matching lines...) Expand all Loading... |
2408 0x00, 0x00, 0x00, 0x04, | 2402 0x00, 0x00, 0x00, 0x04, |
2409 0x00, 0x00, 0x00, 0x00, // Stream Id | 2403 0x00, 0x00, 0x00, 0x00, // Stream Id |
2410 }; | 2404 }; |
2411 const unsigned char kV3FrameData[] = { | 2405 const unsigned char kV3FrameData[] = { |
2412 0x80, spdy_version_ch_, 0x00, 0x07, | 2406 0x80, spdy_version_ch_, 0x00, 0x07, |
2413 0x00, 0x00, 0x00, 0x08, | 2407 0x00, 0x00, 0x00, 0x08, |
2414 0x00, 0x00, 0x00, 0x00, // Stream Id | 2408 0x00, 0x00, 0x00, 0x00, // Stream Id |
2415 0x00, 0x00, 0x00, 0x00, // Status | 2409 0x00, 0x00, 0x00, 0x00, // Status |
2416 }; | 2410 }; |
2417 const unsigned char kV4FrameData[] = { | 2411 const unsigned char kV4FrameData[] = { |
2418 0x00, 0x12, 0x07, 0x00, | 2412 0x00, 0x0a, 0x07, 0x00, |
2419 0x00, 0x00, 0x00, 0x00, | 2413 0x00, 0x00, 0x00, 0x00, |
2420 0x00, 0x00, 0x00, 0x00, // Stream id | 2414 0x00, 0x00, 0x00, 0x00, // Stream id |
2421 0x00, 0x00, 0x00, 0x00, // Status | 2415 0x00, 0x00, 0x00, 0x00, // Status |
2422 0x47, 0x41, // Opaque Description | 2416 0x47, 0x41, // Opaque Description |
2423 }; | 2417 }; |
2424 SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA"); | 2418 SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA"); |
2425 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); | 2419 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); |
2426 if (IsSpdy2()) { | 2420 if (IsSpdy2()) { |
2427 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2421 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2428 } else if (IsSpdy3()) { | 2422 } else if (IsSpdy3()) { |
(...skipping 10 matching lines...) Expand all Loading... |
2439 0x00, 0x00, 0x00, 0x04, | 2433 0x00, 0x00, 0x00, 0x04, |
2440 0x7f, 0xff, 0xff, 0xff, // Stream Id | 2434 0x7f, 0xff, 0xff, 0xff, // Stream Id |
2441 }; | 2435 }; |
2442 const unsigned char kV3FrameData[] = { | 2436 const unsigned char kV3FrameData[] = { |
2443 0x80, spdy_version_ch_, 0x00, 0x07, | 2437 0x80, spdy_version_ch_, 0x00, 0x07, |
2444 0x00, 0x00, 0x00, 0x08, | 2438 0x00, 0x00, 0x00, 0x08, |
2445 0x7f, 0xff, 0xff, 0xff, // Stream Id | 2439 0x7f, 0xff, 0xff, 0xff, // Stream Id |
2446 0x00, 0x00, 0x00, 0x02, // Status | 2440 0x00, 0x00, 0x00, 0x02, // Status |
2447 }; | 2441 }; |
2448 const unsigned char kV4FrameData[] = { | 2442 const unsigned char kV4FrameData[] = { |
2449 0x00, 0x12, 0x07, 0x00, | 2443 0x00, 0x0a, 0x07, 0x00, |
2450 0x00, 0x00, 0x00, 0x00, | 2444 0x00, 0x00, 0x00, 0x00, |
2451 0x7f, 0xff, 0xff, 0xff, // Stream Id | 2445 0x7f, 0xff, 0xff, 0xff, // Stream Id |
2452 0x00, 0x00, 0x00, 0x02, // Status | 2446 0x00, 0x00, 0x00, 0x02, // Status |
2453 0x47, 0x41, // Opaque Description | 2447 0x47, 0x41, // Opaque Description |
2454 }; | 2448 }; |
2455 SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA"); | 2449 SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA"); |
2456 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); | 2450 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); |
2457 if (IsSpdy2()) { | 2451 if (IsSpdy2()) { |
2458 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2452 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2459 } else if (IsSpdy3()) { | 2453 } else if (IsSpdy3()) { |
(...skipping 29 matching lines...) Expand all Loading... |
2489 0x00, 0x00, 0x00, 0x02, | 2483 0x00, 0x00, 0x00, 0x02, |
2490 0x00, 0x00, 0x00, 0x03, | 2484 0x00, 0x00, 0x00, 0x03, |
2491 'b', 'a', 'r', 0x00, | 2485 'b', 'a', 'r', 0x00, |
2492 0x00, 0x00, 0x03, 'f', | 2486 0x00, 0x00, 0x03, 'f', |
2493 'o', 'o', 0x00, 0x00, | 2487 'o', 'o', 0x00, 0x00, |
2494 0x00, 0x03, 'f', 'o', | 2488 0x00, 0x03, 'f', 'o', |
2495 'o', 0x00, 0x00, 0x00, | 2489 'o', 0x00, 0x00, 0x00, |
2496 0x03, 'b', 'a', 'r' | 2490 0x03, 'b', 'a', 'r' |
2497 }; | 2491 }; |
2498 const unsigned char kV4FrameData[] = { | 2492 const unsigned char kV4FrameData[] = { |
2499 0x00, 0x1a, 0x08, 0x04, // Headers: END_HEADERS | 2493 0x00, 0x12, 0x08, 0x04, // Headers: END_HEADERS |
2500 0x00, 0x00, 0x00, 0x01, // Stream 1 | 2494 0x00, 0x00, 0x00, 0x01, // Stream 1 |
2501 0x40, 0x03, 0x62, 0x61, // @.ba | 2495 0x40, 0x03, 0x62, 0x61, // @.ba |
2502 0x72, 0x03, 0x66, 0x6f, // r.fo | 2496 0x72, 0x03, 0x66, 0x6f, // r.fo |
2503 0x6f, 0x40, 0x03, 0x66, // o@.f | 2497 0x6f, 0x40, 0x03, 0x66, // o@.f |
2504 0x6f, 0x6f, 0x03, 0x62, // oo.b | 2498 0x6f, 0x6f, 0x03, 0x62, // oo.b |
2505 0x61, 0x72, // ar | 2499 0x61, 0x72, // ar |
2506 }; | 2500 }; |
2507 SpdyHeadersIR headers_ir(1); | 2501 SpdyHeadersIR headers_ir(1); |
2508 headers_ir.SetHeader("bar", "foo"); | 2502 headers_ir.SetHeader("bar", "foo"); |
2509 headers_ir.SetHeader("foo", "bar"); | 2503 headers_ir.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
2539 0x00, 0x00, 0x00, 0x02, | 2533 0x00, 0x00, 0x00, 0x02, |
2540 0x00, 0x00, 0x00, 0x00, | 2534 0x00, 0x00, 0x00, 0x00, |
2541 0x00, 0x00, 0x00, 0x03, | 2535 0x00, 0x00, 0x00, 0x03, |
2542 'f', 'o', 'o', 0x00, | 2536 'f', 'o', 'o', 0x00, |
2543 0x00, 0x00, 0x03, 'f', | 2537 0x00, 0x00, 0x03, 'f', |
2544 'o', 'o', 0x00, 0x00, | 2538 'o', 'o', 0x00, 0x00, |
2545 0x00, 0x03, 'b', 'a', | 2539 0x00, 0x03, 'b', 'a', |
2546 'r' | 2540 'r' |
2547 }; | 2541 }; |
2548 const unsigned char kV4FrameData[] = { | 2542 const unsigned char kV4FrameData[] = { |
2549 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 2543 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS |
2550 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 2544 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
2551 0x40, 0x00, 0x03, 0x66, // @..f | 2545 0x40, 0x00, 0x03, 0x66, // @..f |
2552 0x6f, 0x6f, 0x40, 0x03, // oo@. | 2546 0x6f, 0x6f, 0x40, 0x03, // oo@. |
2553 0x66, 0x6f, 0x6f, 0x03, // foo. | 2547 0x66, 0x6f, 0x6f, 0x03, // foo. |
2554 0x62, 0x61, 0x72, // bar | 2548 0x62, 0x61, 0x72, // bar |
2555 }; | 2549 }; |
2556 SpdyHeadersIR headers_ir(0x7fffffff); | 2550 SpdyHeadersIR headers_ir(0x7fffffff); |
2557 headers_ir.set_fin(true); | 2551 headers_ir.set_fin(true); |
2558 headers_ir.SetHeader("", "foo"); | 2552 headers_ir.SetHeader("", "foo"); |
2559 headers_ir.SetHeader("foo", "bar"); | 2553 headers_ir.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
2589 0x00, 0x00, 0x00, 0x02, | 2583 0x00, 0x00, 0x00, 0x02, |
2590 0x00, 0x00, 0x00, 0x03, | 2584 0x00, 0x00, 0x00, 0x03, |
2591 'b', 'a', 'r', 0x00, | 2585 'b', 'a', 'r', 0x00, |
2592 0x00, 0x00, 0x03, 'f', | 2586 0x00, 0x00, 0x03, 'f', |
2593 'o', 'o', 0x00, 0x00, | 2587 'o', 'o', 0x00, 0x00, |
2594 0x00, 0x03, 'f', 'o', | 2588 0x00, 0x03, 'f', 'o', |
2595 'o', 0x00, 0x00, 0x00, | 2589 'o', 0x00, 0x00, 0x00, |
2596 0x00 | 2590 0x00 |
2597 }; | 2591 }; |
2598 const unsigned char kV4FrameData[] = { | 2592 const unsigned char kV4FrameData[] = { |
2599 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 2593 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS |
2600 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 2594 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
2601 0x40, 0x03, 0x62, 0x61, // @.ba | 2595 0x40, 0x03, 0x62, 0x61, // @.ba |
2602 0x72, 0x03, 0x66, 0x6f, // r.fo | 2596 0x72, 0x03, 0x66, 0x6f, // r.fo |
2603 0x6f, 0x40, 0x03, 0x66, // o@.f | 2597 0x6f, 0x40, 0x03, 0x66, // o@.f |
2604 0x6f, 0x6f, 0x00, // oo. | 2598 0x6f, 0x6f, 0x00, // oo. |
2605 }; | 2599 }; |
2606 SpdyHeadersIR headers_ir(0x7fffffff); | 2600 SpdyHeadersIR headers_ir(0x7fffffff); |
2607 headers_ir.set_fin(true); | 2601 headers_ir.set_fin(true); |
2608 headers_ir.SetHeader("bar", "foo"); | 2602 headers_ir.SetHeader("bar", "foo"); |
2609 headers_ir.SetHeader("foo", ""); | 2603 headers_ir.SetHeader("foo", ""); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2682 | 2676 |
2683 { | 2677 { |
2684 const char kDescription[] = "WINDOW_UPDATE frame"; | 2678 const char kDescription[] = "WINDOW_UPDATE frame"; |
2685 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2679 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2686 0x80, spdy_version_ch_, 0x00, 0x09, | 2680 0x80, spdy_version_ch_, 0x00, 0x09, |
2687 0x00, 0x00, 0x00, 0x08, | 2681 0x00, 0x00, 0x00, 0x08, |
2688 0x00, 0x00, 0x00, 0x01, | 2682 0x00, 0x00, 0x00, 0x01, |
2689 0x00, 0x00, 0x00, 0x01, | 2683 0x00, 0x00, 0x00, 0x01, |
2690 }; | 2684 }; |
2691 const unsigned char kV4FrameData[] = { | 2685 const unsigned char kV4FrameData[] = { |
2692 0x00, 0x0c, 0x09, 0x00, | 2686 0x00, 0x04, 0x09, 0x00, |
2693 0x00, 0x00, 0x00, 0x01, | 2687 0x00, 0x00, 0x00, 0x01, |
2694 0x00, 0x00, 0x00, 0x01, | 2688 0x00, 0x00, 0x00, 0x01, |
2695 }; | 2689 }; |
2696 scoped_ptr<SpdyFrame> frame( | 2690 scoped_ptr<SpdyFrame> frame( |
2697 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1))); | 2691 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1))); |
2698 if (IsSpdy4()) { | 2692 if (IsSpdy4()) { |
2699 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2693 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2700 } else { | 2694 } else { |
2701 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2695 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2702 } | 2696 } |
2703 } | 2697 } |
2704 | 2698 |
2705 { | 2699 { |
2706 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; | 2700 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; |
2707 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2701 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2708 0x80, spdy_version_ch_, 0x00, 0x09, | 2702 0x80, spdy_version_ch_, 0x00, 0x09, |
2709 0x00, 0x00, 0x00, 0x08, | 2703 0x00, 0x00, 0x00, 0x08, |
2710 0x7f, 0xff, 0xff, 0xff, | 2704 0x7f, 0xff, 0xff, 0xff, |
2711 0x00, 0x00, 0x00, 0x01, | 2705 0x00, 0x00, 0x00, 0x01, |
2712 }; | 2706 }; |
2713 const unsigned char kV4FrameData[] = { | 2707 const unsigned char kV4FrameData[] = { |
2714 0x00, 0x0c, 0x09, 0x00, | 2708 0x00, 0x04, 0x09, 0x00, |
2715 0x7f, 0xff, 0xff, 0xff, | 2709 0x7f, 0xff, 0xff, 0xff, |
2716 0x00, 0x00, 0x00, 0x01, | 2710 0x00, 0x00, 0x00, 0x01, |
2717 }; | 2711 }; |
2718 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 2712 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
2719 net::SpdyWindowUpdateIR(0x7FFFFFFF, 1))); | 2713 net::SpdyWindowUpdateIR(0x7FFFFFFF, 1))); |
2720 if (IsSpdy4()) { | 2714 if (IsSpdy4()) { |
2721 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2715 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2722 } else { | 2716 } else { |
2723 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2717 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2724 } | 2718 } |
2725 } | 2719 } |
2726 | 2720 |
2727 { | 2721 { |
2728 const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; | 2722 const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; |
2729 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2723 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2730 0x80, spdy_version_ch_, 0x00, 0x09, | 2724 0x80, spdy_version_ch_, 0x00, 0x09, |
2731 0x00, 0x00, 0x00, 0x08, | 2725 0x00, 0x00, 0x00, 0x08, |
2732 0x00, 0x00, 0x00, 0x01, | 2726 0x00, 0x00, 0x00, 0x01, |
2733 0x7f, 0xff, 0xff, 0xff, | 2727 0x7f, 0xff, 0xff, 0xff, |
2734 }; | 2728 }; |
2735 const unsigned char kV4FrameData[] = { | 2729 const unsigned char kV4FrameData[] = { |
2736 0x00, 0x0c, 0x09, 0x00, | 2730 0x00, 0x04, 0x09, 0x00, |
2737 0x00, 0x00, 0x00, 0x01, | 2731 0x00, 0x00, 0x00, 0x01, |
2738 0x7f, 0xff, 0xff, 0xff, | 2732 0x7f, 0xff, 0xff, 0xff, |
2739 }; | 2733 }; |
2740 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 2734 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
2741 net::SpdyWindowUpdateIR(1, 0x7FFFFFFF))); | 2735 net::SpdyWindowUpdateIR(1, 0x7FFFFFFF))); |
2742 if (IsSpdy4()) { | 2736 if (IsSpdy4()) { |
2743 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2737 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2744 } else { | 2738 } else { |
2745 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2739 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2746 } | 2740 } |
2747 } | 2741 } |
2748 } | 2742 } |
2749 | 2743 |
2750 TEST_P(SpdyFramerTest, SerializeBlocked) { | 2744 TEST_P(SpdyFramerTest, SerializeBlocked) { |
2751 if (spdy_version_ < SPDY4) { | 2745 if (spdy_version_ < SPDY4) { |
2752 return; | 2746 return; |
2753 } | 2747 } |
2754 | 2748 |
2755 SpdyFramer framer(spdy_version_); | 2749 SpdyFramer framer(spdy_version_); |
2756 | 2750 |
2757 const char kDescription[] = "BLOCKED frame"; | 2751 const char kDescription[] = "BLOCKED frame"; |
2758 const unsigned char kFrameData[] = { | 2752 const unsigned char kFrameData[] = { |
2759 0x00, 0x08, 0x0b, 0x00, | 2753 0x00, 0x00, 0x0b, 0x00, |
2760 0x00, 0x00, 0x00, 0x00, | 2754 0x00, 0x00, 0x00, 0x00, |
2761 }; | 2755 }; |
2762 SpdyBlockedIR blocked_ir(0); | 2756 SpdyBlockedIR blocked_ir(0); |
2763 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 2757 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
2764 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 2758 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
2765 } | 2759 } |
2766 | 2760 |
2767 TEST_P(SpdyFramerTest, CreateBlocked) { | 2761 TEST_P(SpdyFramerTest, CreateBlocked) { |
2768 if (spdy_version_ < SPDY4) { | 2762 if (spdy_version_ < SPDY4) { |
2769 return; | 2763 return; |
(...skipping 16 matching lines...) Expand all Loading... |
2786 TEST_P(SpdyFramerTest, CreatePushPromise) { | 2780 TEST_P(SpdyFramerTest, CreatePushPromise) { |
2787 if (spdy_version_ < SPDY4) { | 2781 if (spdy_version_ < SPDY4) { |
2788 return; | 2782 return; |
2789 } | 2783 } |
2790 | 2784 |
2791 SpdyFramer framer(spdy_version_); | 2785 SpdyFramer framer(spdy_version_); |
2792 | 2786 |
2793 const char kDescription[] = "PUSH_PROMISE frame"; | 2787 const char kDescription[] = "PUSH_PROMISE frame"; |
2794 | 2788 |
2795 const unsigned char kFrameData[] = { | 2789 const unsigned char kFrameData[] = { |
2796 0x00, 0x1e, 0x0c, 0x04, // PUSH_PROMISE: END_HEADERS | 2790 0x00, 0x16, 0x0c, 0x04, // PUSH_PROMISE: END_HEADERS |
2797 0x00, 0x00, 0x00, 0x2a, // Stream 42 | 2791 0x00, 0x00, 0x00, 0x2a, // Stream 42 |
2798 0x00, 0x00, 0x00, 0x39, // Promised stream 57 | 2792 0x00, 0x00, 0x00, 0x39, // Promised stream 57 |
2799 0x40, 0x03, 0x62, 0x61, // @.ba | 2793 0x40, 0x03, 0x62, 0x61, // @.ba |
2800 0x72, 0x03, 0x66, 0x6f, // r.fo | 2794 0x72, 0x03, 0x66, 0x6f, // r.fo |
2801 0x6f, 0x40, 0x03, 0x66, // o@.f | 2795 0x6f, 0x40, 0x03, 0x66, // o@.f |
2802 0x6f, 0x6f, 0x03, 0x62, // oo.b | 2796 0x6f, 0x6f, 0x03, 0x62, // oo.b |
2803 0x61, 0x72, // ar | 2797 0x61, 0x72, // ar |
2804 }; | 2798 }; |
2805 | 2799 |
2806 SpdyPushPromiseIR push_promise(42, 57); | 2800 SpdyPushPromiseIR push_promise(42, 57); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3053 const unsigned char length = 1 + SpdyFramer::kControlFrameBufferSize; | 3047 const unsigned char length = 1 + SpdyFramer::kControlFrameBufferSize; |
3054 const unsigned char kV3FrameData[] = { // Also applies for V2. | 3048 const unsigned char kV3FrameData[] = { // Also applies for V2. |
3055 0x80, spdy_version_ch_, 0x00, 0x07, | 3049 0x80, spdy_version_ch_, 0x00, 0x07, |
3056 0x00, 0x00, 0x00, length, | 3050 0x00, 0x00, 0x00, length, |
3057 0x00, 0x00, 0x00, 0x00, // Stream ID | 3051 0x00, 0x00, 0x00, 0x00, // Stream ID |
3058 0x00, 0x00, 0x00, 0x00, // Status | 3052 0x00, 0x00, 0x00, 0x00, // Status |
3059 }; | 3053 }; |
3060 | 3054 |
3061 // SPDY version 4 and up GOAWAY frames are only bound to a minimal length, | 3055 // SPDY version 4 and up GOAWAY frames are only bound to a minimal length, |
3062 // since it may carry opaque data. Verify that minimal length is tested. | 3056 // since it may carry opaque data. Verify that minimal length is tested. |
3063 const unsigned char less_than_min_length = framer.GetGoAwayMinimumSize() - 1; | 3057 const unsigned char less_than_min_length = |
| 3058 framer.GetGoAwayMinimumSize() - framer.GetControlFrameHeaderSize() - 1; |
3064 const unsigned char kV4FrameData[] = { | 3059 const unsigned char kV4FrameData[] = { |
3065 0x00, static_cast<uint8>(less_than_min_length), 0x07, 0x00, | 3060 0x00, static_cast<uint8>(less_than_min_length), 0x07, 0x00, |
3066 0x00, 0x00, 0x00, 0x00, | 3061 0x00, 0x00, 0x00, 0x00, |
3067 0x00, 0x00, 0x00, 0x00, // Stream Id | 3062 0x00, 0x00, 0x00, 0x00, // Stream Id |
3068 0x00, 0x00, 0x00, 0x00, // Status | 3063 0x00, 0x00, 0x00, 0x00, // Status |
3069 }; | 3064 }; |
3070 const size_t pad_length = | 3065 const size_t pad_length = |
3071 length + framer.GetControlFrameHeaderSize() - | 3066 length + framer.GetControlFrameHeaderSize() - |
3072 (IsSpdy4() ? sizeof(kV4FrameData) : sizeof(kV3FrameData)); | 3067 (IsSpdy4() ? sizeof(kV4FrameData) : sizeof(kV3FrameData)); |
3073 string pad('A', pad_length); | 3068 string pad('A', pad_length); |
(...skipping 18 matching lines...) Expand all Loading... |
3092 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { | 3087 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { |
3093 SpdyFramer framer(spdy_version_); | 3088 SpdyFramer framer(spdy_version_); |
3094 SpdySettingsIR settings_ir; | 3089 SpdySettingsIR settings_ir; |
3095 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); | 3090 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); |
3096 SetFrameLength(control_frame.get(), 0, spdy_version_); | 3091 SetFrameLength(control_frame.get(), 0, spdy_version_); |
3097 TestSpdyVisitor visitor(spdy_version_); | 3092 TestSpdyVisitor visitor(spdy_version_); |
3098 visitor.use_compression_ = false; | 3093 visitor.use_compression_ = false; |
3099 visitor.SimulateInFramer( | 3094 visitor.SimulateInFramer( |
3100 reinterpret_cast<unsigned char*>(control_frame->data()), | 3095 reinterpret_cast<unsigned char*>(control_frame->data()), |
3101 framer.GetControlFrameHeaderSize()); | 3096 framer.GetControlFrameHeaderSize()); |
3102 // Should generate an error, since zero-len settings frames are unsupported. | 3097 if (spdy_version_ < 4) { |
3103 EXPECT_EQ(1, visitor.error_count_); | 3098 // Should generate an error, since zero-len settings frames are unsupported. |
| 3099 EXPECT_EQ(1, visitor.error_count_); |
| 3100 } else { |
| 3101 // Zero-len settings frames are permitted as of SPDY 4. |
| 3102 EXPECT_EQ(0, visitor.error_count_); |
| 3103 } |
3104 } | 3104 } |
3105 | 3105 |
3106 // Tests handling of SETTINGS frames with invalid length. | 3106 // Tests handling of SETTINGS frames with invalid length. |
3107 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { | 3107 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { |
3108 SpdyFramer framer(spdy_version_); | 3108 SpdyFramer framer(spdy_version_); |
3109 SpdySettingsIR settings_ir; | 3109 SpdySettingsIR settings_ir; |
3110 | 3110 |
3111 // Add a setting to pad the frame so that we don't get a buffer overflow when | 3111 // Add a setting to pad the frame so that we don't get a buffer overflow when |
3112 // calling SimulateInFramer() below. | 3112 // calling SimulateInFramer() below. |
3113 SettingsMap settings; | 3113 SettingsMap settings; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 0x00, 0x00, 0x00, 0x1C, | 3206 0x00, 0x00, 0x00, 0x1C, |
3207 0x00, 0x00, 0x00, 0x03, | 3207 0x00, 0x00, 0x00, 0x03, |
3208 0x00, 0x00, 0x00, 0x01, // 1st Setting | 3208 0x00, 0x00, 0x00, 0x01, // 1st Setting |
3209 0x00, 0x00, 0x00, 0x02, | 3209 0x00, 0x00, 0x00, 0x02, |
3210 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting | 3210 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting |
3211 0x00, 0x00, 0x00, 0x03, | 3211 0x00, 0x00, 0x00, 0x03, |
3212 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting | 3212 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting |
3213 0x00, 0x00, 0x00, 0x03, | 3213 0x00, 0x00, 0x00, 0x03, |
3214 }; | 3214 }; |
3215 const unsigned char kV4FrameData[] = { | 3215 const unsigned char kV4FrameData[] = { |
3216 0x00, 0x17, 0x04, 0x00, | 3216 0x00, 0x0f, 0x04, 0x00, |
3217 0x00, 0x00, 0x00, 0x00, | 3217 0x00, 0x00, 0x00, 0x00, |
3218 0x01, // 1st Setting | 3218 0x01, // 1st Setting |
3219 0x00, 0x00, 0x00, 0x02, | 3219 0x00, 0x00, 0x00, 0x02, |
3220 0x01, // 2nd (duplicate) Setting | 3220 0x01, // 2nd (duplicate) Setting |
3221 0x00, 0x00, 0x00, 0x03, | 3221 0x00, 0x00, 0x00, 0x03, |
3222 0x03, // 3rd (unprocessed) Setting | 3222 0x03, // 3rd (unprocessed) Setting |
3223 0x00, 0x00, 0x00, 0x03, | 3223 0x00, 0x00, 0x00, 0x03, |
3224 }; | 3224 }; |
3225 | 3225 |
3226 TestSpdyVisitor visitor(spdy_version_); | 3226 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3265 0x00, 0x00, 0x00, 0x1C, | 3265 0x00, 0x00, 0x00, 0x1C, |
3266 0x00, 0x00, 0x00, 0x03, | 3266 0x00, 0x00, 0x00, 0x03, |
3267 0x00, 0x00, 0x00, 0x02, // 1st Setting | 3267 0x00, 0x00, 0x00, 0x02, // 1st Setting |
3268 0x00, 0x00, 0x00, 0x02, | 3268 0x00, 0x00, 0x00, 0x02, |
3269 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting | 3269 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting |
3270 0x00, 0x00, 0x00, 0x03, | 3270 0x00, 0x00, 0x00, 0x03, |
3271 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting | 3271 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting |
3272 0x00, 0x00, 0x00, 0x03, | 3272 0x00, 0x00, 0x00, 0x03, |
3273 }; | 3273 }; |
3274 const unsigned char kV4FrameData[] = { | 3274 const unsigned char kV4FrameData[] = { |
3275 0x00, 0x17, 0x04, 0x00, | 3275 0x00, 0x0f, 0x04, 0x00, |
3276 0x00, 0x00, 0x00, 0x00, | 3276 0x00, 0x00, 0x00, 0x00, |
3277 0x02, // 1st Setting | 3277 0x02, // 1st Setting |
3278 0x00, 0x00, 0x00, 0x02, | 3278 0x00, 0x00, 0x00, 0x02, |
3279 0x01, // 2nd (out of order) Setting | 3279 0x01, // 2nd (out of order) Setting |
3280 0x00, 0x00, 0x00, 0x03, | 3280 0x00, 0x00, 0x00, 0x03, |
3281 0x03, // 3rd (unprocessed) Setting | 3281 0x03, // 3rd (unprocessed) Setting |
3282 0x00, 0x00, 0x00, 0x03, | 3282 0x00, 0x00, 0x00, 0x03, |
3283 }; | 3283 }; |
3284 | 3284 |
3285 TestSpdyVisitor visitor(spdy_version_); | 3285 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 17 matching lines...) Expand all Loading... |
3303 } | 3303 } |
3304 } | 3304 } |
3305 | 3305 |
3306 TEST_P(SpdyFramerTest, ProcessSettingsAckFrame) { | 3306 TEST_P(SpdyFramerTest, ProcessSettingsAckFrame) { |
3307 if (spdy_version_ < 4) { | 3307 if (spdy_version_ < 4) { |
3308 return; | 3308 return; |
3309 } | 3309 } |
3310 SpdyFramer framer(spdy_version_); | 3310 SpdyFramer framer(spdy_version_); |
3311 | 3311 |
3312 const unsigned char kFrameData[] = { | 3312 const unsigned char kFrameData[] = { |
3313 0x00, 0x08, 0x04, 0x01, | 3313 0x00, 0x00, 0x04, 0x01, |
3314 0x00, 0x00, 0x00, 0x00, | 3314 0x00, 0x00, 0x00, 0x00, |
3315 }; | 3315 }; |
3316 | 3316 |
3317 TestSpdyVisitor visitor(spdy_version_); | 3317 TestSpdyVisitor visitor(spdy_version_); |
3318 visitor.use_compression_ = false; | 3318 visitor.use_compression_ = false; |
3319 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 3319 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
3320 | 3320 |
3321 EXPECT_EQ(0, visitor.error_count_); | 3321 EXPECT_EQ(0, visitor.error_count_); |
3322 EXPECT_EQ(0, visitor.setting_count_); | 3322 EXPECT_EQ(0, visitor.setting_count_); |
3323 EXPECT_EQ(1, visitor.settings_ack_received_); | 3323 EXPECT_EQ(1, visitor.settings_ack_received_); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3473 TEST_P(SpdyFramerTest, CreateContinuation) { | 3473 TEST_P(SpdyFramerTest, CreateContinuation) { |
3474 if (spdy_version_ < SPDY4) { | 3474 if (spdy_version_ < SPDY4) { |
3475 return; | 3475 return; |
3476 } | 3476 } |
3477 | 3477 |
3478 SpdyFramer framer(spdy_version_); | 3478 SpdyFramer framer(spdy_version_); |
3479 | 3479 |
3480 const char kDescription[] = "CONTINUATION frame"; | 3480 const char kDescription[] = "CONTINUATION frame"; |
3481 | 3481 |
3482 const unsigned char kFrameData[] = { | 3482 const unsigned char kFrameData[] = { |
3483 0x00, 0x1a, 0x0d, 0x00, // CONTINUATION | 3483 0x00, 0x12, 0x0d, 0x00, // CONTINUATION |
3484 0x00, 0x00, 0x00, 0x2a, // Stream 42 | 3484 0x00, 0x00, 0x00, 0x2a, // Stream 42 |
3485 0x40, 0x03, 0x62, 0x61, // @.ba | 3485 0x40, 0x03, 0x62, 0x61, // @.ba |
3486 0x72, 0x03, 0x66, 0x6f, // r.fo | 3486 0x72, 0x03, 0x66, 0x6f, // r.fo |
3487 0x6f, 0x40, 0x03, 0x66, // o@.f | 3487 0x6f, 0x40, 0x03, 0x66, // o@.f |
3488 0x6f, 0x6f, 0x03, 0x62, // oo.b | 3488 0x6f, 0x6f, 0x03, 0x62, // oo.b |
3489 0x61, 0x72, // ar | 3489 0x61, 0x72, // ar |
3490 }; | 3490 }; |
3491 | 3491 |
3492 SpdyContinuationIR continuation(42); | 3492 SpdyContinuationIR continuation(42); |
3493 continuation.SetHeader("bar", "foo"); | 3493 continuation.SetHeader("bar", "foo"); |
(...skipping 25 matching lines...) Expand all Loading... |
3519 EXPECT_EQ(57u, visitor.last_push_promise_promised_stream_); | 3519 EXPECT_EQ(57u, visitor.last_push_promise_promised_stream_); |
3520 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); | 3520 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); |
3521 } | 3521 } |
3522 | 3522 |
3523 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) { | 3523 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) { |
3524 if (spdy_version_ < 4) { | 3524 if (spdy_version_ < 4) { |
3525 return; | 3525 return; |
3526 } | 3526 } |
3527 | 3527 |
3528 const unsigned char kInput[] = { | 3528 const unsigned char kInput[] = { |
3529 0x00, 0x18, 0x08, 0x00, // HEADERS | 3529 0x00, 0x10, 0x08, 0x00, // HEADERS |
3530 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3530 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3531 0x40, 0x06, 0x43, 0x6f, | 3531 0x40, 0x06, 0x43, 0x6f, |
3532 0x6f, 0x6b, 0x69, 0x65, | 3532 0x6f, 0x6b, 0x69, 0x65, |
3533 0x07, 0x66, 0x6f, 0x6f, | 3533 0x07, 0x66, 0x6f, 0x6f, |
3534 0x3d, 0x62, 0x61, 0x72, | 3534 0x3d, 0x62, 0x61, 0x72, |
3535 | 3535 |
3536 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3536 0x00, 0x14, 0x0D, 0x00, // CONTINUATION |
3537 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3537 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3538 0x40, 0x06, 0x43, 0x6f, | 3538 0x40, 0x06, 0x43, 0x6f, |
3539 0x6f, 0x6b, 0x69, 0x65, | 3539 0x6f, 0x6b, 0x69, 0x65, |
3540 0x08, 0x62, 0x61, 0x7a, | 3540 0x08, 0x62, 0x61, 0x7a, |
3541 0x3d, 0x62, 0x69, 0x6e, | 3541 0x3d, 0x62, 0x69, 0x6e, |
3542 0x67, 0x40, 0x06, 0x43, | 3542 0x67, 0x40, 0x06, 0x43, |
3543 | 3543 |
3544 0x00, 0x1a, 0x0D, 0x04, // CONTINUATION: END_HEADERS | 3544 0x00, 0x12, 0x0D, 0x04, // CONTINUATION: END_HEADERS |
3545 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3545 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3546 0x6f, 0x6f, 0x6b, 0x69, | 3546 0x6f, 0x6f, 0x6b, 0x69, |
3547 0x65, 0x00, 0x40, 0x04, | 3547 0x65, 0x00, 0x40, 0x04, |
3548 0x6e, 0x61, 0x6d, 0x65, | 3548 0x6e, 0x61, 0x6d, 0x65, |
3549 0x05, 0x76, 0x61, 0x6c, | 3549 0x05, 0x76, 0x61, 0x6c, |
3550 0x75, 0x65, | 3550 0x75, 0x65, |
3551 }; | 3551 }; |
3552 | 3552 |
3553 SpdyFramer framer(spdy_version_); | 3553 SpdyFramer framer(spdy_version_); |
3554 TestSpdyVisitor visitor(spdy_version_); | 3554 TestSpdyVisitor visitor(spdy_version_); |
3555 visitor.SimulateInFramer(kInput, sizeof(kInput)); | 3555 visitor.SimulateInFramer(kInput, sizeof(kInput)); |
3556 | 3556 |
3557 EXPECT_EQ(0, visitor.error_count_); | 3557 EXPECT_EQ(0, visitor.error_count_); |
3558 EXPECT_EQ(1, visitor.headers_frame_count_); | 3558 EXPECT_EQ(1, visitor.headers_frame_count_); |
3559 EXPECT_EQ(2, visitor.continuation_count_); | 3559 EXPECT_EQ(2, visitor.continuation_count_); |
3560 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); | 3560 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
3561 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); | 3561 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); |
3562 | 3562 |
3563 EXPECT_THAT(visitor.headers_, ElementsAre( | 3563 EXPECT_THAT(visitor.headers_, ElementsAre( |
3564 Pair("Cookie", "foo=bar; baz=bing; "), | 3564 Pair("Cookie", "foo=bar; baz=bing; "), |
3565 Pair("name", "value"))); | 3565 Pair("name", "value"))); |
3566 } | 3566 } |
3567 | 3567 |
3568 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) { | 3568 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) { |
3569 if (spdy_version_ < 4) { | 3569 if (spdy_version_ < 4) { |
3570 return; | 3570 return; |
3571 } | 3571 } |
3572 | 3572 |
3573 const unsigned char kInput[] = { | 3573 const unsigned char kInput[] = { |
3574 0x00, 0x18, 0x08, 0x01, // HEADERS: FIN | 3574 0x00, 0x10, 0x08, 0x01, // HEADERS: FIN |
3575 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3575 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3576 0x40, 0x06, 0x43, 0x6f, | 3576 0x40, 0x06, 0x43, 0x6f, |
3577 0x6f, 0x6b, 0x69, 0x65, | 3577 0x6f, 0x6b, 0x69, 0x65, |
3578 0x07, 0x66, 0x6f, 0x6f, | 3578 0x07, 0x66, 0x6f, 0x6f, |
3579 0x3d, 0x62, 0x61, 0x72, | 3579 0x3d, 0x62, 0x61, 0x72, |
3580 | 3580 |
3581 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3581 0x00, 0x14, 0x0D, 0x00, // CONTINUATION |
3582 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3582 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3583 0x40, 0x06, 0x43, 0x6f, | 3583 0x40, 0x06, 0x43, 0x6f, |
3584 0x6f, 0x6b, 0x69, 0x65, | 3584 0x6f, 0x6b, 0x69, 0x65, |
3585 0x08, 0x62, 0x61, 0x7a, | 3585 0x08, 0x62, 0x61, 0x7a, |
3586 0x3d, 0x62, 0x69, 0x6e, | 3586 0x3d, 0x62, 0x69, 0x6e, |
3587 0x67, 0x40, 0x06, 0x43, | 3587 0x67, 0x40, 0x06, 0x43, |
3588 | 3588 |
3589 0x00, 0x1a, 0x0D, 0x04, // CONTINUATION: END_HEADERS | 3589 0x00, 0x12, 0x0D, 0x04, // CONTINUATION: END_HEADERS |
3590 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3590 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3591 0x6f, 0x6f, 0x6b, 0x69, | 3591 0x6f, 0x6f, 0x6b, 0x69, |
3592 0x65, 0x00, 0x40, 0x04, | 3592 0x65, 0x00, 0x40, 0x04, |
3593 0x6e, 0x61, 0x6d, 0x65, | 3593 0x6e, 0x61, 0x6d, 0x65, |
3594 0x05, 0x76, 0x61, 0x6c, | 3594 0x05, 0x76, 0x61, 0x6c, |
3595 0x75, 0x65, | 3595 0x75, 0x65, |
3596 }; | 3596 }; |
3597 | 3597 |
3598 SpdyFramer framer(spdy_version_); | 3598 SpdyFramer framer(spdy_version_); |
3599 TestSpdyVisitor visitor(spdy_version_); | 3599 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 10 matching lines...) Expand all Loading... |
3610 Pair("Cookie", "foo=bar; baz=bing; "), | 3610 Pair("Cookie", "foo=bar; baz=bing; "), |
3611 Pair("name", "value"))); | 3611 Pair("name", "value"))); |
3612 } | 3612 } |
3613 | 3613 |
3614 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) { | 3614 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) { |
3615 if (spdy_version_ < 4) { | 3615 if (spdy_version_ < 4) { |
3616 return; | 3616 return; |
3617 } | 3617 } |
3618 | 3618 |
3619 const unsigned char kInput[] = { | 3619 const unsigned char kInput[] = { |
3620 0x00, 0x1c, 0x0C, 0x00, // PUSH_PROMISE | 3620 0x00, 0x14, 0x0C, 0x00, // PUSH_PROMISE |
3621 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3621 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3622 0x00, 0x00, 0x00, 0x2A, // Promised stream 42 | 3622 0x00, 0x00, 0x00, 0x2A, // Promised stream 42 |
3623 0x40, 0x06, 0x43, 0x6f, | 3623 0x40, 0x06, 0x43, 0x6f, |
3624 0x6f, 0x6b, 0x69, 0x65, | 3624 0x6f, 0x6b, 0x69, 0x65, |
3625 0x07, 0x66, 0x6f, 0x6f, | 3625 0x07, 0x66, 0x6f, 0x6f, |
3626 0x3d, 0x62, 0x61, 0x72, | 3626 0x3d, 0x62, 0x61, 0x72, |
3627 | 3627 |
3628 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3628 0x00, 0x14, 0x0D, 0x00, // CONTINUATION |
3629 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3629 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3630 0x40, 0x06, 0x43, 0x6f, | 3630 0x40, 0x06, 0x43, 0x6f, |
3631 0x6f, 0x6b, 0x69, 0x65, | 3631 0x6f, 0x6b, 0x69, 0x65, |
3632 0x08, 0x62, 0x61, 0x7a, | 3632 0x08, 0x62, 0x61, 0x7a, |
3633 0x3d, 0x62, 0x69, 0x6e, | 3633 0x3d, 0x62, 0x69, 0x6e, |
3634 0x67, 0x40, 0x06, 0x43, | 3634 0x67, 0x40, 0x06, 0x43, |
3635 | 3635 |
3636 0x00, 0x1a, 0x0D, 0x04, // CONTINUATION: END_HEADERS | 3636 0x00, 0x12, 0x0D, 0x04, // CONTINUATION: END_HEADERS |
3637 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3637 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3638 0x6f, 0x6f, 0x6b, 0x69, | 3638 0x6f, 0x6f, 0x6b, 0x69, |
3639 0x65, 0x00, 0x40, 0x04, | 3639 0x65, 0x00, 0x40, 0x04, |
3640 0x6e, 0x61, 0x6d, 0x65, | 3640 0x6e, 0x61, 0x6d, 0x65, |
3641 0x05, 0x76, 0x61, 0x6c, | 3641 0x05, 0x76, 0x61, 0x6c, |
3642 0x75, 0x65, | 3642 0x75, 0x65, |
3643 }; | 3643 }; |
3644 | 3644 |
3645 SpdyFramer framer(spdy_version_); | 3645 SpdyFramer framer(spdy_version_); |
3646 TestSpdyVisitor visitor(spdy_version_); | 3646 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 10 matching lines...) Expand all Loading... |
3657 Pair("Cookie", "foo=bar; baz=bing; "), | 3657 Pair("Cookie", "foo=bar; baz=bing; "), |
3658 Pair("name", "value"))); | 3658 Pair("name", "value"))); |
3659 } | 3659 } |
3660 | 3660 |
3661 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) { | 3661 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) { |
3662 if (spdy_version_ < 4) { | 3662 if (spdy_version_ < 4) { |
3663 return; | 3663 return; |
3664 } | 3664 } |
3665 | 3665 |
3666 const unsigned char kInput[] = { | 3666 const unsigned char kInput[] = { |
3667 0x00, 0x18, 0x08, 0x00, // HEADERS | 3667 0x00, 0x10, 0x08, 0x00, // HEADERS |
3668 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3668 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3669 0x40, 0x06, 0x43, 0x6f, | 3669 0x40, 0x06, 0x43, 0x6f, |
3670 0x6f, 0x6b, 0x69, 0x65, | 3670 0x6f, 0x6b, 0x69, 0x65, |
3671 0x07, 0x66, 0x6f, 0x6f, | 3671 0x07, 0x66, 0x6f, 0x6f, |
3672 0x3d, 0x62, 0x61, 0x72, | 3672 0x3d, 0x62, 0x61, 0x72, |
3673 | 3673 |
3674 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3674 0x00, 0x14, 0x0D, 0x00, // CONTINUATION |
3675 0x00, 0x00, 0x00, 0x02, // Stream 2 | 3675 0x00, 0x00, 0x00, 0x02, // Stream 2 |
3676 0x40, 0x06, 0x43, 0x6f, | 3676 0x40, 0x06, 0x43, 0x6f, |
3677 0x6f, 0x6b, 0x69, 0x65, | 3677 0x6f, 0x6b, 0x69, 0x65, |
3678 0x08, 0x62, 0x61, 0x7a, | 3678 0x08, 0x62, 0x61, 0x7a, |
3679 0x3d, 0x62, 0x69, 0x6e, | 3679 0x3d, 0x62, 0x69, 0x6e, |
3680 0x67, 0x40, 0x06, 0x43, | 3680 0x67, 0x40, 0x06, 0x43, |
3681 }; | 3681 }; |
3682 | 3682 |
3683 SpdyFramer framer(spdy_version_); | 3683 SpdyFramer framer(spdy_version_); |
3684 TestSpdyVisitor visitor(spdy_version_); | 3684 TestSpdyVisitor visitor(spdy_version_); |
3685 framer.set_visitor(&visitor); | 3685 framer.set_visitor(&visitor); |
3686 visitor.SimulateInFramer(kInput, sizeof(kInput)); | 3686 visitor.SimulateInFramer(kInput, sizeof(kInput)); |
3687 | 3687 |
3688 EXPECT_EQ(1, visitor.error_count_); | 3688 EXPECT_EQ(1, visitor.error_count_); |
3689 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 3689 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
3690 visitor.framer_.error_code()) | 3690 visitor.framer_.error_code()) |
3691 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3691 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3692 EXPECT_EQ(1, visitor.headers_frame_count_); | 3692 EXPECT_EQ(1, visitor.headers_frame_count_); |
3693 EXPECT_EQ(0, visitor.continuation_count_); | 3693 EXPECT_EQ(0, visitor.continuation_count_); |
3694 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3694 EXPECT_EQ(0u, visitor.header_buffer_length_); |
3695 } | 3695 } |
3696 | 3696 |
3697 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) { | 3697 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) { |
3698 if (spdy_version_ < 4) { | 3698 if (spdy_version_ < 4) { |
3699 return; | 3699 return; |
3700 } | 3700 } |
3701 | 3701 |
3702 const unsigned char kInput[] = { | 3702 const unsigned char kInput[] = { |
3703 0x00, 0x18, 0x0D, 0x00, // CONTINUATION | 3703 0x00, 0x10, 0x0D, 0x00, // CONTINUATION |
3704 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3704 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3705 0x40, 0x06, 0x43, 0x6f, | 3705 0x40, 0x06, 0x43, 0x6f, |
3706 0x6f, 0x6b, 0x69, 0x65, | 3706 0x6f, 0x6b, 0x69, 0x65, |
3707 0x07, 0x66, 0x6f, 0x6f, | 3707 0x07, 0x66, 0x6f, 0x6f, |
3708 0x3d, 0x62, 0x61, 0x72, | 3708 0x3d, 0x62, 0x61, 0x72, |
3709 }; | 3709 }; |
3710 | 3710 |
3711 SpdyFramer framer(spdy_version_); | 3711 SpdyFramer framer(spdy_version_); |
3712 TestSpdyVisitor visitor(spdy_version_); | 3712 TestSpdyVisitor visitor(spdy_version_); |
3713 framer.set_visitor(&visitor); | 3713 framer.set_visitor(&visitor); |
3714 visitor.SimulateInFramer(kInput, sizeof(kInput)); | 3714 visitor.SimulateInFramer(kInput, sizeof(kInput)); |
3715 | 3715 |
3716 EXPECT_EQ(1, visitor.error_count_); | 3716 EXPECT_EQ(1, visitor.error_count_); |
3717 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME, | 3717 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME, |
3718 visitor.framer_.error_code()) | 3718 visitor.framer_.error_code()) |
3719 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3719 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3720 EXPECT_EQ(0, visitor.continuation_count_); | 3720 EXPECT_EQ(0, visitor.continuation_count_); |
3721 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3721 EXPECT_EQ(0u, visitor.header_buffer_length_); |
3722 } | 3722 } |
3723 | 3723 |
3724 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) { | 3724 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) { |
3725 if (spdy_version_ < 4) { | 3725 if (spdy_version_ < 4) { |
3726 return; | 3726 return; |
3727 } | 3727 } |
3728 | 3728 |
3729 const unsigned char kInput[] = { | 3729 const unsigned char kInput[] = { |
3730 0x00, 0x18, 0x08, 0x00, // HEADERS | 3730 0x00, 0x10, 0x08, 0x00, // HEADERS |
3731 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3731 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3732 0x40, 0x06, 0x43, 0x6f, | 3732 0x40, 0x06, 0x43, 0x6f, |
3733 0x6f, 0x6b, 0x69, 0x65, | 3733 0x6f, 0x6b, 0x69, 0x65, |
3734 0x07, 0x66, 0x6f, 0x6f, | 3734 0x07, 0x66, 0x6f, 0x6f, |
3735 0x3d, 0x62, 0x61, 0x72, | 3735 0x3d, 0x62, 0x61, 0x72, |
3736 | 3736 |
3737 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 | 3737 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 |
3738 0x00, 0x00, 0x00, 0x04, | 3738 0x00, 0x00, 0x00, 0x04, |
3739 0xde, 0xad, 0xbe, 0xef, | 3739 0xde, 0xad, 0xbe, 0xef, |
3740 }; | 3740 }; |
(...skipping 12 matching lines...) Expand all Loading... |
3753 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3753 EXPECT_EQ(0u, visitor.header_buffer_length_); |
3754 EXPECT_EQ(0, visitor.data_frame_count_); | 3754 EXPECT_EQ(0, visitor.data_frame_count_); |
3755 } | 3755 } |
3756 | 3756 |
3757 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) { | 3757 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) { |
3758 if (spdy_version_ < 4) { | 3758 if (spdy_version_ < 4) { |
3759 return; | 3759 return; |
3760 } | 3760 } |
3761 | 3761 |
3762 const unsigned char kInput[] = { | 3762 const unsigned char kInput[] = { |
3763 0x00, 0x18, 0x08, 0x00, // HEADERS | 3763 0x00, 0x10, 0x08, 0x00, // HEADERS |
3764 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3764 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3765 0x40, 0x06, 0x43, 0x6f, | 3765 0x40, 0x06, 0x43, 0x6f, |
3766 0x6f, 0x6b, 0x69, 0x65, | 3766 0x6f, 0x6b, 0x69, 0x65, |
3767 0x07, 0x66, 0x6f, 0x6f, | 3767 0x07, 0x66, 0x6f, 0x6f, |
3768 0x3d, 0x62, 0x61, 0x72, | 3768 0x3d, 0x62, 0x61, 0x72, |
3769 | 3769 |
3770 0x00, 0x1c, 0x08, 0x00, // HEADERS | 3770 0x00, 0x14, 0x08, 0x00, // HEADERS |
3771 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3771 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3772 0x40, 0x06, 0x43, 0x6f, // (Note this is a valid continued encoding). | 3772 0x40, 0x06, 0x43, 0x6f, // (Note this is a valid continued encoding). |
3773 0x6f, 0x6b, 0x69, 0x65, | 3773 0x6f, 0x6b, 0x69, 0x65, |
3774 0x08, 0x62, 0x61, 0x7a, | 3774 0x08, 0x62, 0x61, 0x7a, |
3775 0x3d, 0x62, 0x69, 0x6e, | 3775 0x3d, 0x62, 0x69, 0x6e, |
3776 0x67, 0x40, 0x06, 0x43, | 3776 0x67, 0x40, 0x06, 0x43, |
3777 }; | 3777 }; |
3778 | 3778 |
3779 SpdyFramer framer(spdy_version_); | 3779 SpdyFramer framer(spdy_version_); |
3780 TestSpdyVisitor visitor(spdy_version_); | 3780 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 13 matching lines...) Expand all Loading... |
3794 TEST_P(SpdyFramerTest, ReadGarbage) { | 3794 TEST_P(SpdyFramerTest, ReadGarbage) { |
3795 SpdyFramer framer(spdy_version_); | 3795 SpdyFramer framer(spdy_version_); |
3796 unsigned char garbage_frame[256]; | 3796 unsigned char garbage_frame[256]; |
3797 memset(garbage_frame, ~0, sizeof(garbage_frame)); | 3797 memset(garbage_frame, ~0, sizeof(garbage_frame)); |
3798 TestSpdyVisitor visitor(spdy_version_); | 3798 TestSpdyVisitor visitor(spdy_version_); |
3799 visitor.use_compression_ = false; | 3799 visitor.use_compression_ = false; |
3800 visitor.SimulateInFramer(garbage_frame, sizeof(garbage_frame)); | 3800 visitor.SimulateInFramer(garbage_frame, sizeof(garbage_frame)); |
3801 EXPECT_EQ(1, visitor.error_count_); | 3801 EXPECT_EQ(1, visitor.error_count_); |
3802 } | 3802 } |
3803 | 3803 |
| 3804 TEST_P(SpdyFramerTest, ReadGarbageWithValidLength) { |
| 3805 if (!IsSpdy4()) { |
| 3806 return; |
| 3807 } |
| 3808 SpdyFramer framer(spdy_version_); |
| 3809 const unsigned char kFrameData[] = { |
| 3810 0x00, 0x10, 0xff, 0xff, |
| 3811 0xff, 0xff, 0xff, 0xff, |
| 3812 0xff, 0xff, 0xff, 0xff, |
| 3813 0xff, 0xff, 0xff, 0xff, |
| 3814 }; |
| 3815 TestSpdyVisitor visitor(spdy_version_); |
| 3816 visitor.use_compression_ = false; |
| 3817 visitor.SimulateInFramer(kFrameData, arraysize(kFrameData)); |
| 3818 EXPECT_EQ(1, visitor.error_count_); |
| 3819 } |
| 3820 |
3804 TEST_P(SpdyFramerTest, ReadGarbageWithValidVersion) { | 3821 TEST_P(SpdyFramerTest, ReadGarbageWithValidVersion) { |
3805 if (IsSpdy4()) { | 3822 if (IsSpdy4()) { |
3806 // Not valid for SPDY 4 since there is no version field. | 3823 // Not valid for SPDY 4 since there is no version field. |
3807 return; | 3824 return; |
3808 } | 3825 } |
3809 SpdyFramer framer(spdy_version_); | 3826 SpdyFramer framer(spdy_version_); |
3810 const unsigned char kFrameData[] = { | 3827 const unsigned char kFrameData[] = { |
3811 0x80, spdy_version_ch_, 0xff, 0xff, | 3828 0x80, spdy_version_ch_, 0xff, 0xff, |
3812 0xff, 0xff, 0xff, 0xff, | 3829 0xff, 0xff, 0xff, 0xff, |
3813 }; | 3830 }; |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4585 SpdyFramer framer(spdy_version_); | 4602 SpdyFramer framer(spdy_version_); |
4586 framer.set_visitor(&visitor); | 4603 framer.set_visitor(&visitor); |
4587 framer.set_debug_visitor(&debug_visitor); | 4604 framer.set_debug_visitor(&debug_visitor); |
4588 | 4605 |
4589 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(1, SYN_STREAM, _, _)); | 4606 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(1, SYN_STREAM, _, _)); |
4590 | 4607 |
4591 SpdySynStreamIR syn_stream(1); | 4608 SpdySynStreamIR syn_stream(1); |
4592 syn_stream.set_priority(1); | 4609 syn_stream.set_priority(1); |
4593 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); | 4610 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); |
4594 // Adjust size to remove the name/value block. | 4611 // Adjust size to remove the name/value block. |
4595 if (IsSpdy4()) { | 4612 SetFrameLength( |
4596 SetFrameLength( | 4613 frame.get(), |
4597 frame.get(), | 4614 framer.GetSynStreamMinimumSize() - framer.GetControlFrameHeaderSize(), |
4598 framer.GetSynStreamMinimumSize(), | 4615 spdy_version_); |
4599 spdy_version_); | |
4600 } else { | |
4601 SetFrameLength( | |
4602 frame.get(), | |
4603 framer.GetSynStreamMinimumSize() - framer.GetControlFrameHeaderSize(), | |
4604 spdy_version_); | |
4605 } | |
4606 | 4616 |
4607 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(1, SYN_STREAM, _)); | 4617 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(1, SYN_STREAM, _)); |
4608 EXPECT_CALL(visitor, OnSynStream(1, 0, 1, false, false)); | 4618 EXPECT_CALL(visitor, OnSynStream(1, 0, 1, false, false)); |
4609 EXPECT_CALL(visitor, OnControlFrameHeaderData(1, NULL, 0)); | 4619 EXPECT_CALL(visitor, OnControlFrameHeaderData(1, NULL, 0)); |
4610 | 4620 |
4611 framer.ProcessInput(frame->data(), framer.GetSynStreamMinimumSize()); | 4621 framer.ProcessInput(frame->data(), framer.GetSynStreamMinimumSize()); |
4612 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4622 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4613 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 4623 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
4614 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4624 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
4615 } | 4625 } |
(...skipping 14 matching lines...) Expand all Loading... |
4630 TEST_P(SpdyFramerTest, RstStreamStatusBounds) { | 4640 TEST_P(SpdyFramerTest, RstStreamStatusBounds) { |
4631 DCHECK_GE(0xff, RST_STREAM_NUM_STATUS_CODES); | 4641 DCHECK_GE(0xff, RST_STREAM_NUM_STATUS_CODES); |
4632 | 4642 |
4633 const unsigned char kV3RstStreamInvalid[] = { | 4643 const unsigned char kV3RstStreamInvalid[] = { |
4634 0x80, spdy_version_ch_, 0x00, 0x03, | 4644 0x80, spdy_version_ch_, 0x00, 0x03, |
4635 0x00, 0x00, 0x00, 0x08, | 4645 0x00, 0x00, 0x00, 0x08, |
4636 0x00, 0x00, 0x00, 0x01, | 4646 0x00, 0x00, 0x00, 0x01, |
4637 0x00, 0x00, 0x00, RST_STREAM_INVALID | 4647 0x00, 0x00, 0x00, RST_STREAM_INVALID |
4638 }; | 4648 }; |
4639 const unsigned char kV4RstStreamInvalid[] = { | 4649 const unsigned char kV4RstStreamInvalid[] = { |
4640 0x00, 0x0c, 0x03, 0x00, | 4650 0x00, 0x04, 0x03, 0x00, |
4641 0x00, 0x00, 0x00, 0x01, | 4651 0x00, 0x00, 0x00, 0x01, |
4642 0x00, 0x00, 0x00, RST_STREAM_INVALID | 4652 0x00, 0x00, 0x00, RST_STREAM_INVALID |
4643 }; | 4653 }; |
4644 | 4654 |
4645 const unsigned char kV3RstStreamNumStatusCodes[] = { | 4655 const unsigned char kV3RstStreamNumStatusCodes[] = { |
4646 0x80, spdy_version_ch_, 0x00, 0x03, | 4656 0x80, spdy_version_ch_, 0x00, 0x03, |
4647 0x00, 0x00, 0x00, 0x08, | 4657 0x00, 0x00, 0x00, 0x08, |
4648 0x00, 0x00, 0x00, 0x01, | 4658 0x00, 0x00, 0x00, 0x01, |
4649 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES | 4659 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES |
4650 }; | 4660 }; |
4651 const unsigned char kV4RstStreamNumStatusCodes[] = { | 4661 const unsigned char kV4RstStreamNumStatusCodes[] = { |
4652 0x00, 0x0c, 0x03, 0x00, | 4662 0x00, 0x04, 0x03, 0x00, |
4653 0x00, 0x00, 0x00, 0x01, | 4663 0x00, 0x00, 0x00, 0x01, |
4654 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES | 4664 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES |
4655 }; | 4665 }; |
4656 | 4666 |
4657 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4667 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
4658 SpdyFramer framer(spdy_version_); | 4668 SpdyFramer framer(spdy_version_); |
4659 framer.set_visitor(&visitor); | 4669 framer.set_visitor(&visitor); |
4660 | 4670 |
4661 EXPECT_CALL(visitor, OnRstStream(1, RST_STREAM_INVALID)); | 4671 EXPECT_CALL(visitor, OnRstStream(1, RST_STREAM_INVALID)); |
4662 if (IsSpdy4()) { | 4672 if (IsSpdy4()) { |
(...skipping 29 matching lines...) Expand all Loading... |
4692 0x00, 0x00, 0x00, 0x04, | 4702 0x00, 0x00, 0x00, 0x04, |
4693 0xff, 0xff, 0xff, 0xff, | 4703 0xff, 0xff, 0xff, 0xff, |
4694 }; | 4704 }; |
4695 const unsigned char kV3FrameData[] = { | 4705 const unsigned char kV3FrameData[] = { |
4696 0x80, spdy_version_ch_, 0x00, 0x07, | 4706 0x80, spdy_version_ch_, 0x00, 0x07, |
4697 0x00, 0x00, 0x00, 0x08, | 4707 0x00, 0x00, 0x00, 0x08, |
4698 0xff, 0xff, 0xff, 0xff, | 4708 0xff, 0xff, 0xff, 0xff, |
4699 0x00, 0x00, 0x00, 0x00, | 4709 0x00, 0x00, 0x00, 0x00, |
4700 }; | 4710 }; |
4701 const unsigned char kV4FrameData[] = { | 4711 const unsigned char kV4FrameData[] = { |
4702 0x00, 0x10, 0x07, 0x00, | 4712 0x00, 0x08, 0x07, 0x00, |
4703 0x00, 0x00, 0x00, 0x00, | 4713 0x00, 0x00, 0x00, 0x00, |
4704 0xff, 0xff, 0xff, 0xff, | 4714 0xff, 0xff, 0xff, 0xff, |
4705 0x00, 0x00, 0x00, 0x00, | 4715 0x00, 0x00, 0x00, 0x00, |
4706 }; | 4716 }; |
4707 | 4717 |
4708 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4718 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
4709 SpdyFramer framer(spdy_version_); | 4719 SpdyFramer framer(spdy_version_); |
4710 framer.set_visitor(&visitor); | 4720 framer.set_visitor(&visitor); |
4711 | 4721 |
4712 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); | 4722 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); |
(...skipping 28 matching lines...) Expand all Loading... |
4741 SpdyBlockedIR blocked_ir(0); | 4751 SpdyBlockedIR blocked_ir(0); |
4742 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 4752 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
4743 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); | 4753 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); |
4744 | 4754 |
4745 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4755 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4746 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 4756 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
4747 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4757 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
4748 } | 4758 } |
4749 | 4759 |
4750 } // namespace net | 4760 } // namespace net |
OLD | NEW |