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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 LOG(ERROR) << "Expected header named '" << it->first | 561 LOG(ERROR) << "Expected header named '" << it->first |
568 << "' to have a value of '" << it->second | 562 << "' to have a value of '" << it->second |
569 << "'. The actual value received was '" << it2->second | 563 << "'. The actual value received was '" << it2->second |
570 << "'."; | 564 << "'."; |
571 return false; | 565 return false; |
572 } | 566 } |
573 } | 567 } |
574 return true; | 568 return true; |
575 } | 569 } |
576 | 570 |
577 void AddSpdySettingFromWireFormat(SettingsMap* settings, | |
578 uint32 key, | |
579 uint32 value) { | |
580 SettingsFlagsAndId flags_and_id = | |
581 SettingsFlagsAndId::FromWireFormat(spdy_version_, key); | |
582 SpdySettingsIds id = static_cast<SpdySettingsIds>(flags_and_id.id()); | |
583 SpdySettingsFlags flags = | |
584 static_cast<SpdySettingsFlags>(flags_and_id.flags()); | |
585 CHECK(settings->find(id) == settings->end()); | |
586 settings->insert(std::make_pair(id, SettingsFlagsAndValue(flags, value))); | |
587 } | |
588 | |
589 bool IsSpdy2() { return spdy_version_ == SPDY2; } | 571 bool IsSpdy2() { return spdy_version_ == SPDY2; } |
590 bool IsSpdy3() { return spdy_version_ == SPDY3; } | 572 bool IsSpdy3() { return spdy_version_ == SPDY3; } |
591 bool IsSpdy4() { return spdy_version_ == SPDY4; } | 573 bool IsSpdy4() { return spdy_version_ == SPDY4; } |
592 | 574 |
593 // Version of SPDY protocol to be used. | 575 // Version of SPDY protocol to be used. |
594 SpdyMajorVersion spdy_version_; | 576 SpdyMajorVersion spdy_version_; |
595 unsigned char spdy_version_ch_; | 577 unsigned char spdy_version_ch_; |
596 }; | 578 }; |
597 | 579 |
598 // All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, SPDY/4. | 580 // All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, SPDY/4. |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 | 1028 |
1047 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 | 1029 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 |
1048 0x00, 0x00, 0x00, 0x08, | 1030 0x00, 0x00, 0x00, 0x08, |
1049 0x00, 0x00, 0x00, 0x03, | 1031 0x00, 0x00, 0x00, 0x03, |
1050 0x00, 0x00, 0x00, 0x00, | 1032 0x00, 0x00, 0x00, 0x00, |
1051 }; | 1033 }; |
1052 | 1034 |
1053 // SYN_STREAM doesn't exist in SPDY4, so instead we send | 1035 // SYN_STREAM doesn't exist in SPDY4, so instead we send |
1054 // HEADERS frames with PRIORITY and END_HEADERS set. | 1036 // HEADERS frames with PRIORITY and END_HEADERS set. |
1055 const unsigned char kV4Input[] = { | 1037 const unsigned char kV4Input[] = { |
1056 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1038 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1057 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1039 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1058 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1040 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1059 0x82, // :method: GET | 1041 0x82, // :method: GET |
1060 | 1042 |
1061 0x00, 0x09, 0x08, 0x04, // HEADERS: END_HEADERS | 1043 0x00, 0x01, 0x01, 0x04, // HEADERS: END_HEADERS |
1062 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1044 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1063 0x8c, // :status: 200 | 1045 0x8c, // :status: 200 |
1064 | 1046 |
1065 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1 | 1047 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 |
1066 0x00, 0x00, 0x00, 0x01, | 1048 0x00, 0x00, 0x00, 0x01, |
1067 0xde, 0xad, 0xbe, 0xef, | 1049 0xde, 0xad, 0xbe, 0xef, |
1068 0xde, 0xad, 0xbe, 0xef, | 1050 0xde, 0xad, 0xbe, 0xef, |
1069 0xde, 0xad, 0xbe, 0xef, | 1051 0xde, 0xad, 0xbe, 0xef, |
1070 | 1052 |
1071 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1053 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1072 0x00, 0x00, 0x00, 0x03, // Stream 3 | 1054 0x00, 0x00, 0x00, 0x03, // Stream 3 |
1073 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1055 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1074 0x82, // :method: GET | 1056 0x82, // :method: GET |
1075 | 1057 |
1076 0x00, 0x10, 0x00, 0x00, // DATA on Stream #3 | 1058 0x00, 0x08, 0x00, 0x00, // DATA on Stream #3 |
1077 0x00, 0x00, 0x00, 0x03, | 1059 0x00, 0x00, 0x00, 0x03, |
1078 0xde, 0xad, 0xbe, 0xef, | 1060 0xde, 0xad, 0xbe, 0xef, |
1079 0xde, 0xad, 0xbe, 0xef, | 1061 0xde, 0xad, 0xbe, 0xef, |
1080 | 1062 |
1081 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 | 1063 0x00, 0x04, 0x00, 0x00, // DATA on Stream #1 |
1082 0x00, 0x00, 0x00, 0x01, | 1064 0x00, 0x00, 0x00, 0x01, |
1083 0xde, 0xad, 0xbe, 0xef, | 1065 0xde, 0xad, 0xbe, 0xef, |
1084 | 1066 |
1085 0x00, 0x0c, 0x03, 0x00, // RST_STREAM on Stream #1 | 1067 0x00, 0x04, 0x03, 0x00, // RST_STREAM on Stream #1 |
1086 0x00, 0x00, 0x00, 0x01, | 1068 0x00, 0x00, 0x00, 0x01, |
1087 0x00, 0x00, 0x00, 0x00, | 1069 0x00, 0x00, 0x00, 0x00, |
1088 | 1070 |
1089 0x00, 0x08, 0x00, 0x00, // DATA on Stream #3 | 1071 0x00, 0x00, 0x00, 0x00, // DATA on Stream #3 |
1090 0x00, 0x00, 0x00, 0x03, | 1072 0x00, 0x00, 0x00, 0x03, |
1091 | 1073 |
1092 0x00, 0x17, 0x03, 0x00, // RST_STREAM on Stream #3 | 1074 0x00, 0x0f, 0x03, 0x00, // RST_STREAM on Stream #3 |
1093 0x00, 0x00, 0x00, 0x03, | 1075 0x00, 0x00, 0x00, 0x03, |
1094 0x00, 0x00, 0x00, 0x00, | 1076 0x00, 0x00, 0x00, 0x00, |
1095 0x52, 0x45, 0x53, 0x45, // opaque data | 1077 0x52, 0x45, 0x53, 0x45, // opaque data |
1096 0x54, 0x53, 0x54, 0x52, | 1078 0x54, 0x53, 0x54, 0x52, |
1097 0x45, 0x41, 0x4d, | 1079 0x45, 0x41, 0x4d, |
1098 }; | 1080 }; |
1099 | 1081 |
1100 TestSpdyVisitor visitor(spdy_version_); | 1082 TestSpdyVisitor visitor(spdy_version_); |
1101 if (IsSpdy2()) { | 1083 if (IsSpdy2()) { |
1102 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); | 1084 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 0xde, 0xad, 0xbe, 0xef, | 1163 0xde, 0xad, 0xbe, 0xef, |
1182 | 1164 |
1183 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF | 1165 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF |
1184 0x01, 0x00, 0x00, 0x04, | 1166 0x01, 0x00, 0x00, 0x04, |
1185 0xde, 0xad, 0xbe, 0xef, | 1167 0xde, 0xad, 0xbe, 0xef, |
1186 }; | 1168 }; |
1187 | 1169 |
1188 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send | 1170 // 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. | 1171 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. |
1190 const unsigned char kV4Input[] = { | 1172 const unsigned char kV4Input[] = { |
1191 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1173 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1192 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1174 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1193 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1175 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1194 0x82, // :method: GET | 1176 0x82, // :method: GET |
1195 | 1177 |
1196 0x00, 0x09, 0x08, 0x04, // HEADERS: END_HEADERS | 1178 0x00, 0x01, 0x01, 0x04, // HEADERS: END_HEADERS |
1197 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1179 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1198 0x8c, // :status: 200 | 1180 0x8c, // :status: 200 |
1199 | 1181 |
1200 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1 | 1182 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 |
1201 0x00, 0x00, 0x00, 0x01, | 1183 0x00, 0x00, 0x00, 0x01, |
1202 0xde, 0xad, 0xbe, 0xef, | 1184 0xde, 0xad, 0xbe, 0xef, |
1203 0xde, 0xad, 0xbe, 0xef, | 1185 0xde, 0xad, 0xbe, 0xef, |
1204 0xde, 0xad, 0xbe, 0xef, | 1186 0xde, 0xad, 0xbe, 0xef, |
1205 | 1187 |
1206 0x00, 0x0c, 0x00, 0x01, // DATA on Stream #1, with FIN | 1188 0x00, 0x04, 0x00, 0x01, // DATA on Stream #1, with FIN |
1207 0x00, 0x00, 0x00, 0x01, | 1189 0x00, 0x00, 0x00, 0x01, |
1208 0xde, 0xad, 0xbe, 0xef, | 1190 0xde, 0xad, 0xbe, 0xef, |
1209 }; | 1191 }; |
1210 | 1192 |
1211 TestSpdyVisitor visitor(spdy_version_); | 1193 TestSpdyVisitor visitor(spdy_version_); |
1212 if (IsSpdy2()) { | 1194 if (IsSpdy2()) { |
1213 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); | 1195 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); |
1214 } else if (IsSpdy3()) { | 1196 } else if (IsSpdy3()) { |
1215 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); | 1197 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); |
1216 } else { | 1198 } else { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 0x00, 0x00, 0x00, 0x01, | 1249 0x00, 0x00, 0x00, 0x01, |
1268 0x00, 0x00, 0x00, 0x01, | 1250 0x00, 0x00, 0x00, 0x01, |
1269 0x00, 0x00, 0x00, 0x02, | 1251 0x00, 0x00, 0x00, 0x02, |
1270 'a', 'a', 0x00, 0x00, | 1252 'a', 'a', 0x00, 0x00, |
1271 0x00, 0x02, 'b', 'b', | 1253 0x00, 0x02, 'b', 'b', |
1272 }; | 1254 }; |
1273 | 1255 |
1274 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send | 1256 // 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. | 1257 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. |
1276 const unsigned char kV4Input[] = { | 1258 const unsigned char kV4Input[] = { |
1277 0x00, 0x0d, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1259 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1278 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1260 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1279 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1261 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1280 0x82, // :method: GET | 1262 0x82, // :method: GET |
1281 | 1263 |
1282 0x00, 0x09, 0x08, 0x05, // HEADERS: FIN | END_HEADERS | 1264 0x00, 0x01, 0x01, 0x05, // HEADERS: FIN | END_HEADERS |
1283 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1265 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1284 0x8c, // :status: 200 | 1266 0x8c, // :status: 200 |
1285 }; | 1267 }; |
1286 | 1268 |
1287 TestSpdyVisitor visitor(spdy_version_); | 1269 TestSpdyVisitor visitor(spdy_version_); |
1288 if (IsSpdy2()) { | 1270 if (IsSpdy2()) { |
1289 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); | 1271 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); |
1290 } else if (IsSpdy3()) { | 1272 } else if (IsSpdy3()) { |
1291 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); | 1273 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); |
1292 } else { | 1274 } else { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 net::SpdyWindowUpdateIR(1, 0x12345678))); | 1457 net::SpdyWindowUpdateIR(1, 0x12345678))); |
1476 | 1458 |
1477 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; | 1459 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; |
1478 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1460 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1479 0x80, spdy_version_ch_, 0x00, 0x09, | 1461 0x80, spdy_version_ch_, 0x00, 0x09, |
1480 0x00, 0x00, 0x00, 0x08, | 1462 0x00, 0x00, 0x00, 0x08, |
1481 0x00, 0x00, 0x00, 0x01, | 1463 0x00, 0x00, 0x00, 0x01, |
1482 0x12, 0x34, 0x56, 0x78 | 1464 0x12, 0x34, 0x56, 0x78 |
1483 }; | 1465 }; |
1484 const unsigned char kV4FrameData[] = { | 1466 const unsigned char kV4FrameData[] = { |
1485 0x00, 0x0c, 0x09, 0x00, | 1467 0x00, 0x04, 0x08, 0x00, |
1486 0x00, 0x00, 0x00, 0x01, | 1468 0x00, 0x00, 0x00, 0x01, |
1487 0x12, 0x34, 0x56, 0x78 | 1469 0x12, 0x34, 0x56, 0x78 |
1488 }; | 1470 }; |
1489 | 1471 |
1490 if (IsSpdy4()) { | 1472 if (IsSpdy4()) { |
1491 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1473 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1492 } else { | 1474 } else { |
1493 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1475 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1494 } | 1476 } |
1495 } | 1477 } |
1496 | 1478 |
1497 TEST_P(SpdyFramerTest, CreateDataFrame) { | 1479 TEST_P(SpdyFramerTest, CreateDataFrame) { |
1498 SpdyFramer framer(spdy_version_); | 1480 SpdyFramer framer(spdy_version_); |
1499 | 1481 |
1500 { | 1482 { |
1501 const char kDescription[] = "'hello' data frame, no FIN"; | 1483 const char kDescription[] = "'hello' data frame, no FIN"; |
1502 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1484 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1503 0x00, 0x00, 0x00, 0x01, | 1485 0x00, 0x00, 0x00, 0x01, |
1504 0x00, 0x00, 0x00, 0x05, | 1486 0x00, 0x00, 0x00, 0x05, |
1505 'h', 'e', 'l', 'l', | 1487 'h', 'e', 'l', 'l', |
1506 'o' | 1488 'o' |
1507 }; | 1489 }; |
1508 const unsigned char kV4FrameData[] = { | 1490 const unsigned char kV4FrameData[] = { |
1509 0x00, 0x0d, 0x00, 0x00, | 1491 0x00, 0x05, 0x00, 0x00, |
1510 0x00, 0x00, 0x00, 0x01, | 1492 0x00, 0x00, 0x00, 0x01, |
1511 'h', 'e', 'l', 'l', | 1493 'h', 'e', 'l', 'l', |
1512 'o' | 1494 'o' |
1513 }; | 1495 }; |
1514 const char bytes[] = "hello"; | 1496 const char bytes[] = "hello"; |
1515 | 1497 |
1516 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); | 1498 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); |
1517 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1499 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1518 if (IsSpdy4()) { | 1500 if (IsSpdy4()) { |
1519 CompareFrame( | 1501 CompareFrame( |
1520 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1502 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1521 } else { | 1503 } else { |
1522 CompareFrame( | 1504 CompareFrame( |
1523 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1505 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1524 } | 1506 } |
1525 | 1507 |
1526 SpdyDataIR data_header_ir(1); | 1508 SpdyDataIR data_header_ir(1); |
1527 data_header_ir.SetDataShallow(base::StringPiece(bytes, strlen(bytes))); | 1509 data_header_ir.SetDataShallow(base::StringPiece(bytes, strlen(bytes))); |
1528 frame.reset(framer.SerializeDataFrameHeader(data_header_ir)); | 1510 frame.reset(framer.SerializeDataFrameHeader(data_header_ir)); |
1529 CompareCharArraysWithHexError( | 1511 CompareCharArraysWithHexError( |
1530 kDescription, | 1512 kDescription, |
1531 reinterpret_cast<const unsigned char*>(frame->data()), | 1513 reinterpret_cast<const unsigned char*>(frame->data()), |
1532 framer.GetDataFrameMinimumSize(), | 1514 framer.GetDataFrameMinimumSize(), |
1533 IsSpdy4() ? kV4FrameData : kV3FrameData, | 1515 IsSpdy4() ? kV4FrameData : kV3FrameData, |
1534 framer.GetDataFrameMinimumSize()); | 1516 framer.GetDataFrameMinimumSize()); |
1535 } | 1517 } |
1536 | 1518 |
1537 { | 1519 { |
| 1520 const char kDescription[] = "'hello' data frame with padding, no FIN"; |
| 1521 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 1522 0x00, 0x00, 0x00, 0x01, |
| 1523 0x00, 0x00, 0x00, 0x05, |
| 1524 'h', 'e', 'l', 'l', |
| 1525 'o' |
| 1526 }; |
| 1527 |
| 1528 const unsigned char kV4FrameData[] = { |
| 1529 0x00, 0x0d, 0x00, 0x10, // Length = 13. PAD_LOW set. |
| 1530 0x00, 0x00, 0x00, 0x01, |
| 1531 0x07, // Pad Low field. |
| 1532 'h', 'e', 'l', 'l', // Data |
| 1533 'o', |
| 1534 '0', '0', '0', '0', // Padding |
| 1535 '0', '0', '0' |
| 1536 }; |
| 1537 const char bytes[] = "hello"; |
| 1538 |
| 1539 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); |
| 1540 // 7 zeros and the pad low field make the overal padding to be 8 bytes. |
| 1541 data_ir.set_padding_len(8); |
| 1542 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 1543 if (IsSpdy4()) { |
| 1544 CompareFrame( |
| 1545 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 1546 } else { |
| 1547 CompareFrame( |
| 1548 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 1549 } |
| 1550 } |
| 1551 |
| 1552 { |
1538 const char kDescription[] = "Data frame with negative data byte, no FIN"; | 1553 const char kDescription[] = "Data frame with negative data byte, no FIN"; |
1539 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1554 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1540 0x00, 0x00, 0x00, 0x01, | 1555 0x00, 0x00, 0x00, 0x01, |
1541 0x00, 0x00, 0x00, 0x01, | 1556 0x00, 0x00, 0x00, 0x01, |
1542 0xff | 1557 0xff |
1543 }; | 1558 }; |
1544 const unsigned char kV4FrameData[] = { | 1559 const unsigned char kV4FrameData[] = { |
1545 0x00, 0x09, 0x00, 0x00, | 1560 0x00, 0x01, 0x00, 0x00, |
1546 0x00, 0x00, 0x00, 0x01, | 1561 0x00, 0x00, 0x00, 0x01, |
1547 0xff | 1562 0xff |
1548 }; | 1563 }; |
1549 net::SpdyDataIR data_ir(1, StringPiece("\xff", 1)); | 1564 net::SpdyDataIR data_ir(1, StringPiece("\xff", 1)); |
1550 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1565 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1551 if (IsSpdy4()) { | 1566 if (IsSpdy4()) { |
1552 CompareFrame( | 1567 CompareFrame( |
1553 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1568 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1554 } else { | 1569 } else { |
1555 CompareFrame( | 1570 CompareFrame( |
1556 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1571 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1557 } | 1572 } |
1558 } | 1573 } |
1559 | 1574 |
1560 { | 1575 { |
1561 const char kDescription[] = "'hello' data frame, with FIN"; | 1576 const char kDescription[] = "'hello' data frame, with FIN"; |
1562 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1577 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1563 0x00, 0x00, 0x00, 0x01, | 1578 0x00, 0x00, 0x00, 0x01, |
1564 0x01, 0x00, 0x00, 0x05, | 1579 0x01, 0x00, 0x00, 0x05, |
1565 'h', 'e', 'l', 'l', | 1580 'h', 'e', 'l', 'l', |
1566 'o' | 1581 'o' |
1567 }; | 1582 }; |
1568 const unsigned char kV4FrameData[] = { | 1583 const unsigned char kV4FrameData[] = { |
1569 0x00, 0x0d, 0x00, 0x01, | 1584 0x00, 0x05, 0x00, 0x01, |
1570 0x00, 0x00, 0x00, 0x01, | 1585 0x00, 0x00, 0x00, 0x01, |
1571 'h', 'e', 'l', 'l', | 1586 'h', 'e', 'l', 'l', |
1572 'o' | 1587 'o' |
1573 }; | 1588 }; |
1574 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); | 1589 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
1575 data_ir.set_fin(true); | 1590 data_ir.set_fin(true); |
1576 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1591 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1577 if (IsSpdy4()) { | 1592 if (IsSpdy4()) { |
1578 CompareFrame( | 1593 CompareFrame( |
1579 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1594 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1580 } else { | 1595 } else { |
1581 CompareFrame( | 1596 CompareFrame( |
1582 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1597 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1583 } | 1598 } |
1584 } | 1599 } |
1585 | 1600 |
1586 { | 1601 { |
1587 const char kDescription[] = "Empty data frame"; | 1602 const char kDescription[] = "Empty data frame"; |
1588 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1603 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1589 0x00, 0x00, 0x00, 0x01, | 1604 0x00, 0x00, 0x00, 0x01, |
1590 0x00, 0x00, 0x00, 0x00, | 1605 0x00, 0x00, 0x00, 0x00, |
1591 }; | 1606 }; |
1592 const unsigned char kV4FrameData[] = { | 1607 const unsigned char kV4FrameData[] = { |
1593 0x00, 0x08, 0x00, 0x00, | 1608 0x00, 0x00, 0x00, 0x00, |
1594 0x00, 0x00, 0x00, 0x01, | 1609 0x00, 0x00, 0x00, 0x01, |
1595 }; | 1610 }; |
1596 net::SpdyDataIR data_ir(1, StringPiece()); | 1611 net::SpdyDataIR data_ir(1, StringPiece()); |
1597 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1612 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1598 if (IsSpdy4()) { | 1613 if (IsSpdy4()) { |
1599 CompareFrame( | 1614 CompareFrame( |
1600 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1615 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1601 } else { | 1616 } else { |
1602 CompareFrame( | 1617 CompareFrame( |
1603 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1618 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1604 } | 1619 } |
1605 } | 1620 } |
1606 | 1621 |
1607 { | 1622 { |
1608 const char kDescription[] = "Data frame with max stream ID"; | 1623 const char kDescription[] = "Data frame with max stream ID"; |
1609 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1624 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1610 0x7f, 0xff, 0xff, 0xff, | 1625 0x7f, 0xff, 0xff, 0xff, |
1611 0x01, 0x00, 0x00, 0x05, | 1626 0x01, 0x00, 0x00, 0x05, |
1612 'h', 'e', 'l', 'l', | 1627 'h', 'e', 'l', 'l', |
1613 'o' | 1628 'o' |
1614 }; | 1629 }; |
1615 const unsigned char kV4FrameData[] = { | 1630 const unsigned char kV4FrameData[] = { |
1616 0x00, 0x0d, 0x00, 0x01, | 1631 0x00, 0x05, 0x00, 0x01, |
1617 0x7f, 0xff, 0xff, 0xff, | 1632 0x7f, 0xff, 0xff, 0xff, |
1618 'h', 'e', 'l', 'l', | 1633 'h', 'e', 'l', 'l', |
1619 'o' | 1634 'o' |
1620 }; | 1635 }; |
1621 net::SpdyDataIR data_ir(0x7fffffff, "hello"); | 1636 net::SpdyDataIR data_ir(0x7fffffff, "hello"); |
1622 data_ir.set_fin(true); | 1637 data_ir.set_fin(true); |
1623 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1638 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
1624 if (IsSpdy4()) { | 1639 if (IsSpdy4()) { |
1625 CompareFrame( | 1640 CompareFrame( |
1626 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1641 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1683 0x00, 0x02, 0x00, 0x00, | 1698 0x00, 0x02, 0x00, 0x00, |
1684 0x00, 0x03, 'b', 'a', | 1699 0x00, 0x03, 'b', 'a', |
1685 'r', 0x00, 0x00, 0x00, | 1700 'r', 0x00, 0x00, 0x00, |
1686 0x03, 'f', 'o', 'o', | 1701 0x03, 'f', 'o', 'o', |
1687 0x00, 0x00, 0x00, 0x03, | 1702 0x00, 0x00, 0x00, 0x03, |
1688 'f', 'o', 'o', 0x00, | 1703 'f', 'o', 'o', 0x00, |
1689 0x00, 0x00, 0x03, 'b', | 1704 0x00, 0x00, 0x03, 'b', |
1690 'a', 'r' | 1705 'a', 'r' |
1691 }; | 1706 }; |
1692 const unsigned char kV4FrameData[] = { | 1707 const unsigned char kV4FrameData[] = { |
1693 0x00, 0x1e, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS | 1708 0x00, 0x16, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS |
1694 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1709 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1695 0x00, 0x00, 0x00, 0x07, // Priority 7 | 1710 0x00, 0x00, 0x00, 0x07, // Priority 7 |
1696 0x40, 0x03, 0x62, 0x61, // @.ba | 1711 0x40, 0x03, 0x62, 0x61, // @.ba |
1697 0x72, 0x03, 0x66, 0x6f, // r.fo | 1712 0x72, 0x03, 0x66, 0x6f, // r.fo |
1698 0x6f, 0x40, 0x03, 0x66, // o@.f | 1713 0x6f, 0x40, 0x03, 0x66, // o@.f |
1699 0x6f, 0x6f, 0x03, 0x62, // oo.b | 1714 0x6f, 0x6f, 0x03, 0x62, // oo.b |
1700 0x61, 0x72, // ar | 1715 0x61, 0x72, // ar |
1701 }; | 1716 }; |
1702 SpdySynStreamIR syn_stream(1); | 1717 SpdySynStreamIR syn_stream(1); |
1703 syn_stream.set_priority(framer.GetLowestPriority()); | 1718 syn_stream.set_priority(framer.GetLowestPriority()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 0x00, 0x00, 0x00, 0x00, | 1753 0x00, 0x00, 0x00, 0x00, |
1739 0x00, 0x02, 0x00, 0x00, | 1754 0x00, 0x02, 0x00, 0x00, |
1740 0x00, 0x00, 0x00, 0x00, | 1755 0x00, 0x00, 0x00, 0x00, |
1741 0x00, 0x03, 'f', 'o', | 1756 0x00, 0x03, 'f', 'o', |
1742 'o', 0x00, 0x00, 0x00, | 1757 'o', 0x00, 0x00, 0x00, |
1743 0x03, 'f', 'o', 'o', | 1758 0x03, 'f', 'o', 'o', |
1744 0x00, 0x00, 0x00, 0x03, | 1759 0x00, 0x00, 0x00, 0x03, |
1745 'b', 'a', 'r' | 1760 'b', 'a', 'r' |
1746 }; | 1761 }; |
1747 const unsigned char kV4FrameData[] = { | 1762 const unsigned char kV4FrameData[] = { |
1748 0x00, 0x1b, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS | 1763 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS |
1749 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 1764 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
1750 0x00, 0x00, 0x00, 0x00, // Priority 0 | 1765 0x00, 0x00, 0x00, 0x00, // Priority 0 |
1751 0x40, 0x00, 0x03, 0x66, // @..f | 1766 0x40, 0x00, 0x03, 0x66, // @..f |
1752 0x6f, 0x6f, 0x40, 0x03, // oo@. | 1767 0x6f, 0x6f, 0x40, 0x03, // oo@. |
1753 0x66, 0x6f, 0x6f, 0x03, // foo. | 1768 0x66, 0x6f, 0x6f, 0x03, // foo. |
1754 0x62, 0x61, 0x72, // bar | 1769 0x62, 0x61, 0x72, // bar |
1755 }; | 1770 }; |
1756 SpdySynStreamIR syn_stream(0x7fffffff); | 1771 SpdySynStreamIR syn_stream(0x7fffffff); |
1757 syn_stream.set_associated_to_stream_id(0x7fffffff); | 1772 syn_stream.set_associated_to_stream_id(0x7fffffff); |
1758 syn_stream.set_priority(framer.GetHighestPriority()); | 1773 syn_stream.set_priority(framer.GetHighestPriority()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 kPri, 0x00, 0x00, 0x00, | 1810 kPri, 0x00, 0x00, 0x00, |
1796 0x00, 0x02, 0x00, 0x00, | 1811 0x00, 0x02, 0x00, 0x00, |
1797 0x00, 0x03, 'b', 'a', | 1812 0x00, 0x03, 'b', 'a', |
1798 'r', 0x00, 0x00, 0x00, | 1813 'r', 0x00, 0x00, 0x00, |
1799 0x03, 'f', 'o', 'o', | 1814 0x03, 'f', 'o', 'o', |
1800 0x00, 0x00, 0x00, 0x03, | 1815 0x00, 0x00, 0x00, 0x03, |
1801 'f', 'o', 'o', 0x00, | 1816 'f', 'o', 'o', 0x00, |
1802 0x00, 0x00, 0x00 | 1817 0x00, 0x00, 0x00 |
1803 }; | 1818 }; |
1804 const unsigned char kV4FrameData[] = { | 1819 const unsigned char kV4FrameData[] = { |
1805 0x00, 0x1b, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS | 1820 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS |
1806 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 1821 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
1807 0x00, 0x00, 0x00, 0x01, // Priority 1 | 1822 0x00, 0x00, 0x00, 0x01, // Priority 1 |
1808 0x40, 0x03, 0x62, 0x61, // @.ba | 1823 0x40, 0x03, 0x62, 0x61, // @.ba |
1809 0x72, 0x03, 0x66, 0x6f, // r.fo | 1824 0x72, 0x03, 0x66, 0x6f, // r.fo |
1810 0x6f, 0x40, 0x03, 0x66, // o@.f | 1825 0x6f, 0x40, 0x03, 0x66, // o@.f |
1811 0x6f, 0x6f, 0x00, // oo. | 1826 0x6f, 0x6f, 0x00, // oo. |
1812 }; | 1827 }; |
1813 SpdySynStreamIR syn_stream(0x7fffffff); | 1828 SpdySynStreamIR syn_stream(0x7fffffff); |
1814 syn_stream.set_associated_to_stream_id(0x7fffffff); | 1829 syn_stream.set_associated_to_stream_id(0x7fffffff); |
1815 syn_stream.set_priority(1); | 1830 syn_stream.set_priority(1); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 0x00, 0x00, 0x00, 0x02, | 1931 0x00, 0x00, 0x00, 0x02, |
1917 0x00, 0x00, 0x00, 0x03, | 1932 0x00, 0x00, 0x00, 0x03, |
1918 'b', 'a', 'r', 0x00, | 1933 'b', 'a', 'r', 0x00, |
1919 0x00, 0x00, 0x03, 'f', | 1934 0x00, 0x00, 0x03, 'f', |
1920 'o', 'o', 0x00, 0x00, | 1935 'o', 'o', 0x00, 0x00, |
1921 0x00, 0x03, 'f', 'o', | 1936 0x00, 0x03, 'f', 'o', |
1922 'o', 0x00, 0x00, 0x00, | 1937 'o', 0x00, 0x00, 0x00, |
1923 0x03, 'b', 'a', 'r' | 1938 0x03, 'b', 'a', 'r' |
1924 }; | 1939 }; |
1925 const unsigned char kV4FrameData[] = { | 1940 const unsigned char kV4FrameData[] = { |
1926 0x00, 0x1a, 0x08, 0x04, // HEADER: END_HEADERS | 1941 0x00, 0x12, 0x01, 0x04, // HEADER: END_HEADERS |
1927 0x00, 0x00, 0x00, 0x01, // Stream 1 | 1942 0x00, 0x00, 0x00, 0x01, // Stream 1 |
1928 0x40, 0x03, 0x62, 0x61, // @.ba | 1943 0x40, 0x03, 0x62, 0x61, // @.ba |
1929 0x72, 0x03, 0x66, 0x6f, // r.fo | 1944 0x72, 0x03, 0x66, 0x6f, // r.fo |
1930 0x6f, 0x40, 0x03, 0x66, // o@.f | 1945 0x6f, 0x40, 0x03, 0x66, // o@.f |
1931 0x6f, 0x6f, 0x03, 0x62, // oo.b | 1946 0x6f, 0x6f, 0x03, 0x62, // oo.b |
1932 0x61, 0x72, // ar | 1947 0x61, 0x72, // ar |
1933 }; | 1948 }; |
1934 SpdySynReplyIR syn_reply(1); | 1949 SpdySynReplyIR syn_reply(1); |
1935 syn_reply.SetHeader("bar", "foo"); | 1950 syn_reply.SetHeader("bar", "foo"); |
1936 syn_reply.SetHeader("foo", "bar"); | 1951 syn_reply.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
1966 0x00, 0x00, 0x00, 0x02, | 1981 0x00, 0x00, 0x00, 0x02, |
1967 0x00, 0x00, 0x00, 0x00, | 1982 0x00, 0x00, 0x00, 0x00, |
1968 0x00, 0x00, 0x00, 0x03, | 1983 0x00, 0x00, 0x00, 0x03, |
1969 'f', 'o', 'o', 0x00, | 1984 'f', 'o', 'o', 0x00, |
1970 0x00, 0x00, 0x03, 'f', | 1985 0x00, 0x00, 0x03, 'f', |
1971 'o', 'o', 0x00, 0x00, | 1986 'o', 'o', 0x00, 0x00, |
1972 0x00, 0x03, 'b', 'a', | 1987 0x00, 0x03, 'b', 'a', |
1973 'r' | 1988 'r' |
1974 }; | 1989 }; |
1975 const unsigned char kV4FrameData[] = { | 1990 const unsigned char kV4FrameData[] = { |
1976 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 1991 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS |
1977 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 1992 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
1978 0x40, 0x00, 0x03, 0x66, // @..f | 1993 0x40, 0x00, 0x03, 0x66, // @..f |
1979 0x6f, 0x6f, 0x40, 0x03, // oo@. | 1994 0x6f, 0x6f, 0x40, 0x03, // oo@. |
1980 0x66, 0x6f, 0x6f, 0x03, // foo. | 1995 0x66, 0x6f, 0x6f, 0x03, // foo. |
1981 0x62, 0x61, 0x72, // bar | 1996 0x62, 0x61, 0x72, // bar |
1982 }; | 1997 }; |
1983 SpdySynReplyIR syn_reply(0x7fffffff); | 1998 SpdySynReplyIR syn_reply(0x7fffffff); |
1984 syn_reply.set_fin(true); | 1999 syn_reply.set_fin(true); |
1985 syn_reply.SetHeader("", "foo"); | 2000 syn_reply.SetHeader("", "foo"); |
1986 syn_reply.SetHeader("foo", "bar"); | 2001 syn_reply.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
2016 0x00, 0x00, 0x00, 0x02, | 2031 0x00, 0x00, 0x00, 0x02, |
2017 0x00, 0x00, 0x00, 0x03, | 2032 0x00, 0x00, 0x00, 0x03, |
2018 'b', 'a', 'r', 0x00, | 2033 'b', 'a', 'r', 0x00, |
2019 0x00, 0x00, 0x03, 'f', | 2034 0x00, 0x00, 0x03, 'f', |
2020 'o', 'o', 0x00, 0x00, | 2035 'o', 'o', 0x00, 0x00, |
2021 0x00, 0x03, 'f', 'o', | 2036 0x00, 0x03, 'f', 'o', |
2022 'o', 0x00, 0x00, 0x00, | 2037 'o', 0x00, 0x00, 0x00, |
2023 0x00 | 2038 0x00 |
2024 }; | 2039 }; |
2025 const unsigned char kV4FrameData[] = { | 2040 const unsigned char kV4FrameData[] = { |
2026 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 2041 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS |
2027 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 2042 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
2028 0x40, 0x03, 0x62, 0x61, // @.ba | 2043 0x40, 0x03, 0x62, 0x61, // @.ba |
2029 0x72, 0x03, 0x66, 0x6f, // r.fo | 2044 0x72, 0x03, 0x66, 0x6f, // r.fo |
2030 0x6f, 0x40, 0x03, 0x66, // o@.f | 2045 0x6f, 0x40, 0x03, 0x66, // o@.f |
2031 0x6f, 0x6f, 0x00, // oo. | 2046 0x6f, 0x6f, 0x00, // oo. |
2032 }; | 2047 }; |
2033 SpdySynReplyIR syn_reply(0x7fffffff); | 2048 SpdySynReplyIR syn_reply(0x7fffffff); |
2034 syn_reply.set_fin(true); | 2049 syn_reply.set_fin(true); |
2035 syn_reply.SetHeader("bar", "foo"); | 2050 syn_reply.SetHeader("bar", "foo"); |
2036 syn_reply.SetHeader("foo", ""); | 2051 syn_reply.SetHeader("foo", ""); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 | 2124 |
2110 { | 2125 { |
2111 const char kDescription[] = "RST_STREAM frame"; | 2126 const char kDescription[] = "RST_STREAM frame"; |
2112 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2127 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2113 0x80, spdy_version_ch_, 0x00, 0x03, | 2128 0x80, spdy_version_ch_, 0x00, 0x03, |
2114 0x00, 0x00, 0x00, 0x08, | 2129 0x00, 0x00, 0x00, 0x08, |
2115 0x00, 0x00, 0x00, 0x01, | 2130 0x00, 0x00, 0x00, 0x01, |
2116 0x00, 0x00, 0x00, 0x01, | 2131 0x00, 0x00, 0x00, 0x01, |
2117 }; | 2132 }; |
2118 const unsigned char kV4FrameData[] = { | 2133 const unsigned char kV4FrameData[] = { |
2119 0x00, 0x0f, 0x03, 0x00, | 2134 0x00, 0x07, 0x03, 0x00, |
2120 0x00, 0x00, 0x00, 0x01, | 2135 0x00, 0x00, 0x00, 0x01, |
2121 0x00, 0x00, 0x00, 0x01, | 2136 0x00, 0x00, 0x00, 0x01, |
2122 0x52, 0x53, 0x54 | 2137 0x52, 0x53, 0x54 |
2123 }; | 2138 }; |
2124 net::SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR, "RST"); | 2139 net::SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR, "RST"); |
2125 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2140 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
2126 if (IsSpdy4()) { | 2141 if (IsSpdy4()) { |
2127 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2142 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2128 } else { | 2143 } else { |
2129 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2144 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2130 } | 2145 } |
2131 } | 2146 } |
2132 | 2147 |
2133 { | 2148 { |
2134 const char kDescription[] = "RST_STREAM frame with max stream ID"; | 2149 const char kDescription[] = "RST_STREAM frame with max stream ID"; |
2135 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2150 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2136 0x80, spdy_version_ch_, 0x00, 0x03, | 2151 0x80, spdy_version_ch_, 0x00, 0x03, |
2137 0x00, 0x00, 0x00, 0x08, | 2152 0x00, 0x00, 0x00, 0x08, |
2138 0x7f, 0xff, 0xff, 0xff, | 2153 0x7f, 0xff, 0xff, 0xff, |
2139 0x00, 0x00, 0x00, 0x01, | 2154 0x00, 0x00, 0x00, 0x01, |
2140 }; | 2155 }; |
2141 const unsigned char kV4FrameData[] = { | 2156 const unsigned char kV4FrameData[] = { |
2142 0x00, 0x0c, 0x03, 0x00, | 2157 0x00, 0x04, 0x03, 0x00, |
2143 0x7f, 0xff, 0xff, 0xff, | 2158 0x7f, 0xff, 0xff, 0xff, |
2144 0x00, 0x00, 0x00, 0x01, | 2159 0x00, 0x00, 0x00, 0x01, |
2145 }; | 2160 }; |
2146 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, | 2161 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, |
2147 RST_STREAM_PROTOCOL_ERROR, | 2162 RST_STREAM_PROTOCOL_ERROR, |
2148 ""); | 2163 ""); |
2149 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2164 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
2150 if (IsSpdy4()) { | 2165 if (IsSpdy4()) { |
2151 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2166 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2152 } else { | 2167 } else { |
2153 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2168 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2154 } | 2169 } |
2155 } | 2170 } |
2156 | 2171 |
2157 { | 2172 { |
2158 const char kDescription[] = "RST_STREAM frame with max status code"; | 2173 const char kDescription[] = "RST_STREAM frame with max status code"; |
2159 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2174 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2160 0x80, spdy_version_ch_, 0x00, 0x03, | 2175 0x80, spdy_version_ch_, 0x00, 0x03, |
2161 0x00, 0x00, 0x00, 0x08, | 2176 0x00, 0x00, 0x00, 0x08, |
2162 0x7f, 0xff, 0xff, 0xff, | 2177 0x7f, 0xff, 0xff, 0xff, |
2163 0x00, 0x00, 0x00, 0x06, | 2178 0x00, 0x00, 0x00, 0x06, |
2164 }; | 2179 }; |
2165 const unsigned char kV4FrameData[] = { | 2180 const unsigned char kV4FrameData[] = { |
2166 0x00, 0x0c, 0x03, 0x00, | 2181 0x00, 0x04, 0x03, 0x00, |
2167 0x7f, 0xff, 0xff, 0xff, | 2182 0x7f, 0xff, 0xff, 0xff, |
2168 0x00, 0x00, 0x00, 0x06, | 2183 0x00, 0x00, 0x00, 0x06, |
2169 }; | 2184 }; |
2170 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, | 2185 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, |
2171 RST_STREAM_INTERNAL_ERROR, | 2186 RST_STREAM_INTERNAL_ERROR, |
2172 ""); | 2187 ""); |
2173 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2188 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
2174 if (IsSpdy4()) { | 2189 if (IsSpdy4()) { |
2175 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2190 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2176 } else { | 2191 } else { |
2177 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2192 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2178 } | 2193 } |
2179 } | 2194 } |
2180 } | 2195 } |
2181 | 2196 |
2182 TEST_P(SpdyFramerTest, CreateSettings) { | 2197 TEST_P(SpdyFramerTest, CreateSettings) { |
2183 SpdyFramer framer(spdy_version_); | 2198 SpdyFramer framer(spdy_version_); |
2184 | 2199 |
2185 { | 2200 { |
2186 const char kDescription[] = "Network byte order SETTINGS frame"; | 2201 const char kDescription[] = "Network byte order SETTINGS frame"; |
2187 | 2202 |
2188 const unsigned char kV2FrameData[] = { | 2203 const unsigned char kV2FrameData[] = { |
2189 0x80, spdy_version_ch_, 0x00, 0x04, | 2204 0x80, spdy_version_ch_, 0x00, 0x04, |
2190 0x00, 0x00, 0x00, 0x0c, | 2205 0x00, 0x00, 0x00, 0x0c, |
2191 0x00, 0x00, 0x00, 0x01, | 2206 0x00, 0x00, 0x00, 0x01, |
2192 0x04, 0x03, 0x02, 0x01, | 2207 0x07, 0x00, 0x00, 0x01, |
2193 0x0a, 0x0b, 0x0c, 0x0d, | 2208 0x0a, 0x0b, 0x0c, 0x0d, |
2194 }; | 2209 }; |
2195 const unsigned char kV3FrameData[] = { | 2210 const unsigned char kV3FrameData[] = { |
2196 0x80, spdy_version_ch_, 0x00, 0x04, | 2211 0x80, spdy_version_ch_, 0x00, 0x04, |
2197 0x00, 0x00, 0x00, 0x0c, | 2212 0x00, 0x00, 0x00, 0x0c, |
2198 0x00, 0x00, 0x00, 0x01, | 2213 0x00, 0x00, 0x00, 0x01, |
2199 0x01, 0x02, 0x03, 0x04, | 2214 0x01, 0x00, 0x00, 0x07, |
2200 0x0a, 0x0b, 0x0c, 0x0d, | 2215 0x0a, 0x0b, 0x0c, 0x0d, |
2201 }; | 2216 }; |
2202 const unsigned char kV4FrameData[] = { | 2217 const unsigned char kV4FrameData[] = { |
2203 0x00, 0x0d, 0x04, 0x00, | 2218 0x00, 0x05, 0x04, 0x00, |
2204 0x00, 0x00, 0x00, 0x00, | 2219 0x00, 0x00, 0x00, 0x00, |
2205 0x01, 0x0a, 0x0b, 0x0c, | 2220 0x04, 0x0a, 0x0b, 0x0c, |
2206 0x0d, | 2221 0x0d, |
2207 }; | 2222 }; |
2208 | 2223 |
2209 uint32 kValue = 0x0a0b0c0d; | 2224 uint32 kValue = 0x0a0b0c0d; |
2210 SpdySettingsIR settings_ir; | 2225 SpdySettingsIR settings_ir; |
2211 | 2226 |
2212 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x01); | 2227 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x01); |
2213 SpdySettingsIds kId = static_cast<SpdySettingsIds>(0x020304); | 2228 SpdySettingsIds kId = SETTINGS_INITIAL_WINDOW_SIZE; |
2214 if (IsSpdy4()) { | |
2215 kId = static_cast<SpdySettingsIds>(0x01); | |
2216 } | |
2217 SettingsMap settings; | 2229 SettingsMap settings; |
2218 settings[kId] = SettingsFlagsAndValue(kFlags, kValue); | 2230 settings[kId] = SettingsFlagsAndValue(kFlags, kValue); |
2219 EXPECT_EQ(kFlags, settings[kId].first); | 2231 EXPECT_EQ(kFlags, settings[kId].first); |
2220 EXPECT_EQ(kValue, settings[kId].second); | 2232 EXPECT_EQ(kValue, settings[kId].second); |
2221 settings_ir.AddSetting(kId, | 2233 settings_ir.AddSetting(kId, |
2222 kFlags & SETTINGS_FLAG_PLEASE_PERSIST, | 2234 kFlags & SETTINGS_FLAG_PLEASE_PERSIST, |
2223 kFlags & SETTINGS_FLAG_PERSISTED, | 2235 kFlags & SETTINGS_FLAG_PERSISTED, |
2224 kValue); | 2236 kValue); |
2225 | 2237 |
2226 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); | 2238 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); |
2227 if (IsSpdy2()) { | 2239 if (IsSpdy2()) { |
2228 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2240 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2229 } else if (IsSpdy3()) { | 2241 } else if (IsSpdy3()) { |
2230 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2242 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2231 } else { | 2243 } else { |
2232 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2244 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2233 } | 2245 } |
2234 } | 2246 } |
2235 | 2247 |
2236 { | 2248 { |
2237 const char kDescription[] = "Basic SETTINGS frame"; | 2249 const char kDescription[] = "Basic SETTINGS frame"; |
2238 | 2250 |
2239 SettingsMap settings; | 2251 const unsigned char kV2FrameData[] = { |
2240 AddSpdySettingFromWireFormat( | |
2241 &settings, 0x00000000, 0x00000001); // 1st Setting | |
2242 AddSpdySettingFromWireFormat( | |
2243 &settings, 0x01000001, 0x00000002); // 2nd Setting | |
2244 AddSpdySettingFromWireFormat( | |
2245 &settings, 0x02000002, 0x00000003); // 3rd Setting | |
2246 AddSpdySettingFromWireFormat( | |
2247 &settings, 0x03000003, 0xff000004); // 4th Setting | |
2248 | |
2249 const unsigned char kV3FrameData[] = { // Also applies for V2. | |
2250 0x80, spdy_version_ch_, 0x00, 0x04, | 2252 0x80, spdy_version_ch_, 0x00, 0x04, |
2251 0x00, 0x00, 0x00, 0x24, | 2253 0x00, 0x00, 0x00, 0x24, |
2252 0x00, 0x00, 0x00, 0x04, | 2254 0x00, 0x00, 0x00, 0x04, |
2253 0x00, 0x00, 0x00, 0x00, // 1st Setting | 2255 0x01, 0x00, 0x00, 0x00, // 1st Setting |
2254 0x00, 0x00, 0x00, 0x01, | 2256 0x00, 0x00, 0x00, 0x05, |
2255 0x01, 0x00, 0x00, 0x01, // 2nd Setting | 2257 0x02, 0x00, 0x00, 0x00, // 2nd Setting |
2256 0x00, 0x00, 0x00, 0x02, | 2258 0x00, 0x00, 0x00, 0x06, |
2257 0x02, 0x00, 0x00, 0x02, // 3rd Setting | 2259 0x03, 0x00, 0x00, 0x00, // 3rd Setting |
2258 0x00, 0x00, 0x00, 0x03, | 2260 0x00, 0x00, 0x00, 0x07, |
2259 0x03, 0x00, 0x00, 0x03, // 4th Setting | 2261 0x04, 0x00, 0x00, 0x00, // 4th Setting |
2260 0xff, 0x00, 0x00, 0x04, | 2262 0x00, 0x00, 0x00, 0x08, |
2261 }; | 2263 }; |
| 2264 const unsigned char kV3FrameData[] = { |
| 2265 0x80, spdy_version_ch_, 0x00, 0x04, |
| 2266 0x00, 0x00, 0x00, 0x24, |
| 2267 0x00, 0x00, 0x00, 0x04, |
| 2268 0x00, 0x00, 0x00, 0x01, // 1st Setting |
| 2269 0x00, 0x00, 0x00, 0x05, |
| 2270 0x00, 0x00, 0x00, 0x02, // 2nd Setting |
| 2271 0x00, 0x00, 0x00, 0x06, |
| 2272 0x00, 0x00, 0x00, 0x03, // 3rd Setting |
| 2273 0x00, 0x00, 0x00, 0x07, |
| 2274 0x00, 0x00, 0x00, 0x04, // 4th Setting |
| 2275 0x00, 0x00, 0x00, 0x08, |
| 2276 }; |
| 2277 // These end up seemingly out of order because of the way that our internal |
| 2278 // ordering for settings_ir works. HTTP2 has no requirement on ordering on |
| 2279 // the wire. |
2262 const unsigned char kV4FrameData[] = { | 2280 const unsigned char kV4FrameData[] = { |
2263 0x00, 0x1c, 0x04, 0x00, | 2281 0x00, 0x14, 0x04, 0x00, |
2264 0x00, 0x00, 0x00, 0x00, | 2282 0x00, 0x00, 0x00, 0x00, |
| 2283 0x03, // 3rd Setting |
| 2284 0x00, 0x00, 0x00, 0x07, |
| 2285 0x04, // 4th Setting |
| 2286 0x00, 0x00, 0x00, 0x08, |
2265 0x01, // 1st Setting | 2287 0x01, // 1st Setting |
2266 0x00, 0x00, 0x00, 0x01, | 2288 0x00, 0x00, 0x00, 0x05, |
2267 0x02, // 2nd Setting | 2289 0x02, // 2nd Setting |
2268 0x00, 0x00, 0x00, 0x02, | 2290 0x00, 0x00, 0x00, 0x06, |
2269 0x03, // 3rd Setting | |
2270 0x00, 0x00, 0x00, 0x03, | |
2271 0x04, // 4th Setting | |
2272 0xff, 0x00, 0x00, 0x04, | |
2273 }; | 2291 }; |
| 2292 |
2274 SpdySettingsIR settings_ir; | 2293 SpdySettingsIR settings_ir; |
2275 if (!IsSpdy4()) { | 2294 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 1), |
2276 for (SettingsMap::const_iterator it = settings.begin(); | 2295 false, // persist |
2277 it != settings.end(); | 2296 false, // persisted |
2278 ++it) { | 2297 5); |
2279 settings_ir.AddSetting(it->first, | 2298 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 2), |
2280 it->second.first & SETTINGS_FLAG_PLEASE_PERSIST, | 2299 false, // persist |
2281 it->second.first & SETTINGS_FLAG_PERSISTED, | 2300 false, // persisted |
2282 it->second.second); | 2301 6); |
2283 } | 2302 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 3), |
| 2303 false, // persist |
| 2304 false, // persisted |
| 2305 7); |
| 2306 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 4), |
| 2307 false, // persist |
| 2308 false, // persisted |
| 2309 8); |
| 2310 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); |
| 2311 |
| 2312 if (IsSpdy2()) { |
| 2313 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
| 2314 } else if (IsSpdy3()) { |
| 2315 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2284 } else { | 2316 } else { |
2285 SpdySettingsIds kId = static_cast<SpdySettingsIds>(0x01); | |
2286 settings_ir.AddSetting(kId, 0, 0, 0x00000001); | |
2287 kId = static_cast<SpdySettingsIds>(0x02); | |
2288 settings_ir.AddSetting(kId, 0, 0, 0x00000002); | |
2289 kId = static_cast<SpdySettingsIds>(0x03); | |
2290 settings_ir.AddSetting(kId, 0, 0, 0x00000003); | |
2291 kId = static_cast<SpdySettingsIds>(0x04); | |
2292 settings_ir.AddSetting(kId, 0, 0, 0xff000004); | |
2293 } | |
2294 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); | |
2295 if (IsSpdy4()) { | |
2296 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2317 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2297 } else { | |
2298 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | |
2299 } | 2318 } |
2300 } | 2319 } |
2301 | 2320 |
2302 { | 2321 { |
2303 const char kDescription[] = "Empty SETTINGS frame"; | 2322 const char kDescription[] = "Empty SETTINGS frame"; |
2304 | 2323 |
2305 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2324 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2306 0x80, spdy_version_ch_, 0x00, 0x04, | 2325 0x80, spdy_version_ch_, 0x00, 0x04, |
2307 0x00, 0x00, 0x00, 0x04, | 2326 0x00, 0x00, 0x00, 0x04, |
2308 0x00, 0x00, 0x00, 0x00, | 2327 0x00, 0x00, 0x00, 0x00, |
2309 }; | 2328 }; |
2310 const unsigned char kV4FrameData[] = { | 2329 const unsigned char kV4FrameData[] = { |
2311 0x00, 0x08, 0x04, 0x00, | 2330 0x00, 0x00, 0x04, 0x00, |
2312 0x00, 0x00, 0x00, 0x00, | 2331 0x00, 0x00, 0x00, 0x00, |
2313 }; | 2332 }; |
2314 SpdySettingsIR settings_ir; | 2333 SpdySettingsIR settings_ir; |
2315 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); | 2334 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); |
2316 if (IsSpdy4()) { | 2335 if (IsSpdy4()) { |
2317 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2336 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2318 } else { | 2337 } else { |
2319 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2338 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2320 } | 2339 } |
2321 } | 2340 } |
2322 } | 2341 } |
2323 | 2342 |
2324 TEST_P(SpdyFramerTest, CreatePingFrame) { | 2343 TEST_P(SpdyFramerTest, CreatePingFrame) { |
2325 SpdyFramer framer(spdy_version_); | 2344 SpdyFramer framer(spdy_version_); |
2326 | 2345 |
2327 { | 2346 { |
2328 const char kDescription[] = "PING frame"; | 2347 const char kDescription[] = "PING frame"; |
2329 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2348 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2330 0x80, spdy_version_ch_, 0x00, 0x06, | 2349 0x80, spdy_version_ch_, 0x00, 0x06, |
2331 0x00, 0x00, 0x00, 0x04, | 2350 0x00, 0x00, 0x00, 0x04, |
2332 0x12, 0x34, 0x56, 0x78, | 2351 0x12, 0x34, 0x56, 0x78, |
2333 }; | 2352 }; |
2334 const unsigned char kV4FrameData[] = { | 2353 const unsigned char kV4FrameData[] = { |
2335 0x00, 0x10, 0x06, 0x00, | 2354 0x00, 0x08, 0x06, 0x00, |
2336 0x00, 0x00, 0x00, 0x00, | 2355 0x00, 0x00, 0x00, 0x00, |
2337 0x12, 0x34, 0x56, 0x78, | 2356 0x12, 0x34, 0x56, 0x78, |
2338 0x9a, 0xbc, 0xde, 0xff, | 2357 0x9a, 0xbc, 0xde, 0xff, |
2339 }; | 2358 }; |
2340 const unsigned char kV4FrameDataWithAck[] = { | 2359 const unsigned char kV4FrameDataWithAck[] = { |
2341 0x00, 0x10, 0x06, 0x01, | 2360 0x00, 0x08, 0x06, 0x01, |
2342 0x00, 0x00, 0x00, 0x00, | 2361 0x00, 0x00, 0x00, 0x00, |
2343 0x12, 0x34, 0x56, 0x78, | 2362 0x12, 0x34, 0x56, 0x78, |
2344 0x9a, 0xbc, 0xde, 0xff, | 2363 0x9a, 0xbc, 0xde, 0xff, |
2345 }; | 2364 }; |
2346 scoped_ptr<SpdyFrame> frame; | 2365 scoped_ptr<SpdyFrame> frame; |
2347 if (IsSpdy4()) { | 2366 if (IsSpdy4()) { |
2348 const SpdyPingId kPingId = 0x123456789abcdeffULL; | 2367 const SpdyPingId kPingId = 0x123456789abcdeffULL; |
2349 SpdyPingIR ping_ir(kPingId); | 2368 SpdyPingIR ping_ir(kPingId); |
2350 // Tests SpdyPingIR when the ping is not an ack. | 2369 // Tests SpdyPingIR when the ping is not an ack. |
2351 ASSERT_FALSE(ping_ir.is_ack()); | 2370 ASSERT_FALSE(ping_ir.is_ack()); |
(...skipping 23 matching lines...) Expand all Loading... |
2375 0x00, 0x00, 0x00, 0x04, | 2394 0x00, 0x00, 0x00, 0x04, |
2376 0x00, 0x00, 0x00, 0x00, // Stream Id | 2395 0x00, 0x00, 0x00, 0x00, // Stream Id |
2377 }; | 2396 }; |
2378 const unsigned char kV3FrameData[] = { | 2397 const unsigned char kV3FrameData[] = { |
2379 0x80, spdy_version_ch_, 0x00, 0x07, | 2398 0x80, spdy_version_ch_, 0x00, 0x07, |
2380 0x00, 0x00, 0x00, 0x08, | 2399 0x00, 0x00, 0x00, 0x08, |
2381 0x00, 0x00, 0x00, 0x00, // Stream Id | 2400 0x00, 0x00, 0x00, 0x00, // Stream Id |
2382 0x00, 0x00, 0x00, 0x00, // Status | 2401 0x00, 0x00, 0x00, 0x00, // Status |
2383 }; | 2402 }; |
2384 const unsigned char kV4FrameData[] = { | 2403 const unsigned char kV4FrameData[] = { |
2385 0x00, 0x12, 0x07, 0x00, | 2404 0x00, 0x0a, 0x07, 0x00, |
2386 0x00, 0x00, 0x00, 0x00, | 2405 0x00, 0x00, 0x00, 0x00, |
2387 0x00, 0x00, 0x00, 0x00, // Stream id | 2406 0x00, 0x00, 0x00, 0x00, // Stream id |
2388 0x00, 0x00, 0x00, 0x00, // Status | 2407 0x00, 0x00, 0x00, 0x00, // Status |
2389 0x47, 0x41, // Opaque Description | 2408 0x47, 0x41, // Opaque Description |
2390 }; | 2409 }; |
2391 SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA"); | 2410 SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA"); |
2392 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); | 2411 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); |
2393 if (IsSpdy2()) { | 2412 if (IsSpdy2()) { |
2394 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2413 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2395 } else if (IsSpdy3()) { | 2414 } else if (IsSpdy3()) { |
(...skipping 10 matching lines...) Expand all Loading... |
2406 0x00, 0x00, 0x00, 0x04, | 2425 0x00, 0x00, 0x00, 0x04, |
2407 0x7f, 0xff, 0xff, 0xff, // Stream Id | 2426 0x7f, 0xff, 0xff, 0xff, // Stream Id |
2408 }; | 2427 }; |
2409 const unsigned char kV3FrameData[] = { | 2428 const unsigned char kV3FrameData[] = { |
2410 0x80, spdy_version_ch_, 0x00, 0x07, | 2429 0x80, spdy_version_ch_, 0x00, 0x07, |
2411 0x00, 0x00, 0x00, 0x08, | 2430 0x00, 0x00, 0x00, 0x08, |
2412 0x7f, 0xff, 0xff, 0xff, // Stream Id | 2431 0x7f, 0xff, 0xff, 0xff, // Stream Id |
2413 0x00, 0x00, 0x00, 0x02, // Status | 2432 0x00, 0x00, 0x00, 0x02, // Status |
2414 }; | 2433 }; |
2415 const unsigned char kV4FrameData[] = { | 2434 const unsigned char kV4FrameData[] = { |
2416 0x00, 0x12, 0x07, 0x00, | 2435 0x00, 0x0a, 0x07, 0x00, |
2417 0x00, 0x00, 0x00, 0x00, | 2436 0x00, 0x00, 0x00, 0x00, |
2418 0x7f, 0xff, 0xff, 0xff, // Stream Id | 2437 0x7f, 0xff, 0xff, 0xff, // Stream Id |
2419 0x00, 0x00, 0x00, 0x02, // Status | 2438 0x00, 0x00, 0x00, 0x02, // Status |
2420 0x47, 0x41, // Opaque Description | 2439 0x47, 0x41, // Opaque Description |
2421 }; | 2440 }; |
2422 SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA"); | 2441 SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA"); |
2423 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); | 2442 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); |
2424 if (IsSpdy2()) { | 2443 if (IsSpdy2()) { |
2425 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); | 2444 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); |
2426 } else if (IsSpdy3()) { | 2445 } else if (IsSpdy3()) { |
(...skipping 29 matching lines...) Expand all Loading... |
2456 0x00, 0x00, 0x00, 0x02, | 2475 0x00, 0x00, 0x00, 0x02, |
2457 0x00, 0x00, 0x00, 0x03, | 2476 0x00, 0x00, 0x00, 0x03, |
2458 'b', 'a', 'r', 0x00, | 2477 'b', 'a', 'r', 0x00, |
2459 0x00, 0x00, 0x03, 'f', | 2478 0x00, 0x00, 0x03, 'f', |
2460 'o', 'o', 0x00, 0x00, | 2479 'o', 'o', 0x00, 0x00, |
2461 0x00, 0x03, 'f', 'o', | 2480 0x00, 0x03, 'f', 'o', |
2462 'o', 0x00, 0x00, 0x00, | 2481 'o', 0x00, 0x00, 0x00, |
2463 0x03, 'b', 'a', 'r' | 2482 0x03, 'b', 'a', 'r' |
2464 }; | 2483 }; |
2465 const unsigned char kV4FrameData[] = { | 2484 const unsigned char kV4FrameData[] = { |
2466 0x00, 0x1a, 0x08, 0x04, // Headers: END_HEADERS | 2485 0x00, 0x12, 0x01, 0x04, // Headers: END_HEADERS |
2467 0x00, 0x00, 0x00, 0x01, // Stream 1 | 2486 0x00, 0x00, 0x00, 0x01, // Stream 1 |
2468 0x40, 0x03, 0x62, 0x61, // @.ba | 2487 0x40, 0x03, 0x62, 0x61, // @.ba |
2469 0x72, 0x03, 0x66, 0x6f, // r.fo | 2488 0x72, 0x03, 0x66, 0x6f, // r.fo |
2470 0x6f, 0x40, 0x03, 0x66, // o@.f | 2489 0x6f, 0x40, 0x03, 0x66, // o@.f |
2471 0x6f, 0x6f, 0x03, 0x62, // oo.b | 2490 0x6f, 0x6f, 0x03, 0x62, // oo.b |
2472 0x61, 0x72, // ar | 2491 0x61, 0x72, // ar |
2473 }; | 2492 }; |
2474 SpdyHeadersIR headers_ir(1); | 2493 SpdyHeadersIR headers_ir(1); |
2475 headers_ir.SetHeader("bar", "foo"); | 2494 headers_ir.SetHeader("bar", "foo"); |
2476 headers_ir.SetHeader("foo", "bar"); | 2495 headers_ir.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
2506 0x00, 0x00, 0x00, 0x02, | 2525 0x00, 0x00, 0x00, 0x02, |
2507 0x00, 0x00, 0x00, 0x00, | 2526 0x00, 0x00, 0x00, 0x00, |
2508 0x00, 0x00, 0x00, 0x03, | 2527 0x00, 0x00, 0x00, 0x03, |
2509 'f', 'o', 'o', 0x00, | 2528 'f', 'o', 'o', 0x00, |
2510 0x00, 0x00, 0x03, 'f', | 2529 0x00, 0x00, 0x03, 'f', |
2511 'o', 'o', 0x00, 0x00, | 2530 'o', 'o', 0x00, 0x00, |
2512 0x00, 0x03, 'b', 'a', | 2531 0x00, 0x03, 'b', 'a', |
2513 'r' | 2532 'r' |
2514 }; | 2533 }; |
2515 const unsigned char kV4FrameData[] = { | 2534 const unsigned char kV4FrameData[] = { |
2516 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 2535 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS |
2517 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 2536 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
2518 0x40, 0x00, 0x03, 0x66, // @..f | 2537 0x40, 0x00, 0x03, 0x66, // @..f |
2519 0x6f, 0x6f, 0x40, 0x03, // oo@. | 2538 0x6f, 0x6f, 0x40, 0x03, // oo@. |
2520 0x66, 0x6f, 0x6f, 0x03, // foo. | 2539 0x66, 0x6f, 0x6f, 0x03, // foo. |
2521 0x62, 0x61, 0x72, // bar | 2540 0x62, 0x61, 0x72, // bar |
2522 }; | 2541 }; |
2523 SpdyHeadersIR headers_ir(0x7fffffff); | 2542 SpdyHeadersIR headers_ir(0x7fffffff); |
2524 headers_ir.set_fin(true); | 2543 headers_ir.set_fin(true); |
2525 headers_ir.SetHeader("", "foo"); | 2544 headers_ir.SetHeader("", "foo"); |
2526 headers_ir.SetHeader("foo", "bar"); | 2545 headers_ir.SetHeader("foo", "bar"); |
(...skipping 29 matching lines...) Expand all Loading... |
2556 0x00, 0x00, 0x00, 0x02, | 2575 0x00, 0x00, 0x00, 0x02, |
2557 0x00, 0x00, 0x00, 0x03, | 2576 0x00, 0x00, 0x00, 0x03, |
2558 'b', 'a', 'r', 0x00, | 2577 'b', 'a', 'r', 0x00, |
2559 0x00, 0x00, 0x03, 'f', | 2578 0x00, 0x00, 0x03, 'f', |
2560 'o', 'o', 0x00, 0x00, | 2579 'o', 'o', 0x00, 0x00, |
2561 0x00, 0x03, 'f', 'o', | 2580 0x00, 0x03, 'f', 'o', |
2562 'o', 0x00, 0x00, 0x00, | 2581 'o', 0x00, 0x00, 0x00, |
2563 0x00 | 2582 0x00 |
2564 }; | 2583 }; |
2565 const unsigned char kV4FrameData[] = { | 2584 const unsigned char kV4FrameData[] = { |
2566 0x00, 0x17, 0x08, 0x05, // HEADER: FIN | END_HEADERS | 2585 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS |
2567 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff | 2586 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff |
2568 0x40, 0x03, 0x62, 0x61, // @.ba | 2587 0x40, 0x03, 0x62, 0x61, // @.ba |
2569 0x72, 0x03, 0x66, 0x6f, // r.fo | 2588 0x72, 0x03, 0x66, 0x6f, // r.fo |
2570 0x6f, 0x40, 0x03, 0x66, // o@.f | 2589 0x6f, 0x40, 0x03, 0x66, // o@.f |
2571 0x6f, 0x6f, 0x00, // oo. | 2590 0x6f, 0x6f, 0x00, // oo. |
2572 }; | 2591 }; |
2573 SpdyHeadersIR headers_ir(0x7fffffff); | 2592 SpdyHeadersIR headers_ir(0x7fffffff); |
2574 headers_ir.set_fin(true); | 2593 headers_ir.set_fin(true); |
2575 headers_ir.SetHeader("bar", "foo"); | 2594 headers_ir.SetHeader("bar", "foo"); |
2576 headers_ir.SetHeader("foo", ""); | 2595 headers_ir.SetHeader("foo", ""); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2649 | 2668 |
2650 { | 2669 { |
2651 const char kDescription[] = "WINDOW_UPDATE frame"; | 2670 const char kDescription[] = "WINDOW_UPDATE frame"; |
2652 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2671 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2653 0x80, spdy_version_ch_, 0x00, 0x09, | 2672 0x80, spdy_version_ch_, 0x00, 0x09, |
2654 0x00, 0x00, 0x00, 0x08, | 2673 0x00, 0x00, 0x00, 0x08, |
2655 0x00, 0x00, 0x00, 0x01, | 2674 0x00, 0x00, 0x00, 0x01, |
2656 0x00, 0x00, 0x00, 0x01, | 2675 0x00, 0x00, 0x00, 0x01, |
2657 }; | 2676 }; |
2658 const unsigned char kV4FrameData[] = { | 2677 const unsigned char kV4FrameData[] = { |
2659 0x00, 0x0c, 0x09, 0x00, | 2678 0x00, 0x04, 0x08, 0x00, |
2660 0x00, 0x00, 0x00, 0x01, | 2679 0x00, 0x00, 0x00, 0x01, |
2661 0x00, 0x00, 0x00, 0x01, | 2680 0x00, 0x00, 0x00, 0x01, |
2662 }; | 2681 }; |
2663 scoped_ptr<SpdyFrame> frame( | 2682 scoped_ptr<SpdyFrame> frame( |
2664 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1))); | 2683 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1))); |
2665 if (IsSpdy4()) { | 2684 if (IsSpdy4()) { |
2666 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2685 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2667 } else { | 2686 } else { |
2668 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2687 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2669 } | 2688 } |
2670 } | 2689 } |
2671 | 2690 |
2672 { | 2691 { |
2673 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; | 2692 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; |
2674 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2693 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2675 0x80, spdy_version_ch_, 0x00, 0x09, | 2694 0x80, spdy_version_ch_, 0x00, 0x09, |
2676 0x00, 0x00, 0x00, 0x08, | 2695 0x00, 0x00, 0x00, 0x08, |
2677 0x7f, 0xff, 0xff, 0xff, | 2696 0x7f, 0xff, 0xff, 0xff, |
2678 0x00, 0x00, 0x00, 0x01, | 2697 0x00, 0x00, 0x00, 0x01, |
2679 }; | 2698 }; |
2680 const unsigned char kV4FrameData[] = { | 2699 const unsigned char kV4FrameData[] = { |
2681 0x00, 0x0c, 0x09, 0x00, | 2700 0x00, 0x04, 0x08, 0x00, |
2682 0x7f, 0xff, 0xff, 0xff, | 2701 0x7f, 0xff, 0xff, 0xff, |
2683 0x00, 0x00, 0x00, 0x01, | 2702 0x00, 0x00, 0x00, 0x01, |
2684 }; | 2703 }; |
2685 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 2704 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
2686 net::SpdyWindowUpdateIR(0x7FFFFFFF, 1))); | 2705 net::SpdyWindowUpdateIR(0x7FFFFFFF, 1))); |
2687 if (IsSpdy4()) { | 2706 if (IsSpdy4()) { |
2688 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2707 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2689 } else { | 2708 } else { |
2690 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2709 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2691 } | 2710 } |
2692 } | 2711 } |
2693 | 2712 |
2694 { | 2713 { |
2695 const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; | 2714 const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; |
2696 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2715 const unsigned char kV3FrameData[] = { // Also applies for V2. |
2697 0x80, spdy_version_ch_, 0x00, 0x09, | 2716 0x80, spdy_version_ch_, 0x00, 0x09, |
2698 0x00, 0x00, 0x00, 0x08, | 2717 0x00, 0x00, 0x00, 0x08, |
2699 0x00, 0x00, 0x00, 0x01, | 2718 0x00, 0x00, 0x00, 0x01, |
2700 0x7f, 0xff, 0xff, 0xff, | 2719 0x7f, 0xff, 0xff, 0xff, |
2701 }; | 2720 }; |
2702 const unsigned char kV4FrameData[] = { | 2721 const unsigned char kV4FrameData[] = { |
2703 0x00, 0x0c, 0x09, 0x00, | 2722 0x00, 0x04, 0x08, 0x00, |
2704 0x00, 0x00, 0x00, 0x01, | 2723 0x00, 0x00, 0x00, 0x01, |
2705 0x7f, 0xff, 0xff, 0xff, | 2724 0x7f, 0xff, 0xff, 0xff, |
2706 }; | 2725 }; |
2707 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 2726 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
2708 net::SpdyWindowUpdateIR(1, 0x7FFFFFFF))); | 2727 net::SpdyWindowUpdateIR(1, 0x7FFFFFFF))); |
2709 if (IsSpdy4()) { | 2728 if (IsSpdy4()) { |
2710 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2729 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
2711 } else { | 2730 } else { |
2712 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2731 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
2713 } | 2732 } |
2714 } | 2733 } |
2715 } | 2734 } |
2716 | 2735 |
2717 TEST_P(SpdyFramerTest, SerializeBlocked) { | 2736 TEST_P(SpdyFramerTest, SerializeBlocked) { |
2718 if (spdy_version_ < SPDY4) { | 2737 if (spdy_version_ < SPDY4) { |
2719 return; | 2738 return; |
2720 } | 2739 } |
2721 | 2740 |
2722 SpdyFramer framer(spdy_version_); | 2741 SpdyFramer framer(spdy_version_); |
2723 | 2742 |
2724 const char kDescription[] = "BLOCKED frame"; | 2743 const char kDescription[] = "BLOCKED frame"; |
2725 const unsigned char kFrameData[] = { | 2744 const unsigned char kFrameData[] = { |
2726 0x00, 0x08, 0x0b, 0x00, | 2745 0x00, 0x00, 0x0a, 0x00, |
2727 0x00, 0x00, 0x00, 0x00, | 2746 0x00, 0x00, 0x00, 0x00, |
2728 }; | 2747 }; |
2729 SpdyBlockedIR blocked_ir(0); | 2748 SpdyBlockedIR blocked_ir(0); |
2730 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 2749 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
2731 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 2750 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
2732 } | 2751 } |
2733 | 2752 |
2734 TEST_P(SpdyFramerTest, CreateBlocked) { | 2753 TEST_P(SpdyFramerTest, CreateBlocked) { |
2735 if (spdy_version_ < SPDY4) { | 2754 if (spdy_version_ < SPDY4) { |
2736 return; | 2755 return; |
(...skipping 16 matching lines...) Expand all Loading... |
2753 TEST_P(SpdyFramerTest, CreatePushPromise) { | 2772 TEST_P(SpdyFramerTest, CreatePushPromise) { |
2754 if (spdy_version_ < SPDY4) { | 2773 if (spdy_version_ < SPDY4) { |
2755 return; | 2774 return; |
2756 } | 2775 } |
2757 | 2776 |
2758 SpdyFramer framer(spdy_version_); | 2777 SpdyFramer framer(spdy_version_); |
2759 | 2778 |
2760 const char kDescription[] = "PUSH_PROMISE frame"; | 2779 const char kDescription[] = "PUSH_PROMISE frame"; |
2761 | 2780 |
2762 const unsigned char kFrameData[] = { | 2781 const unsigned char kFrameData[] = { |
2763 0x00, 0x1e, 0x0c, 0x04, // PUSH_PROMISE: END_HEADERS | 2782 0x00, 0x16, 0x05, 0x04, // PUSH_PROMISE: END_HEADERS |
2764 0x00, 0x00, 0x00, 0x2a, // Stream 42 | 2783 0x00, 0x00, 0x00, 0x2a, // Stream 42 |
2765 0x00, 0x00, 0x00, 0x39, // Promised stream 57 | 2784 0x00, 0x00, 0x00, 0x39, // Promised stream 57 |
2766 0x40, 0x03, 0x62, 0x61, // @.ba | 2785 0x40, 0x03, 0x62, 0x61, // @.ba |
2767 0x72, 0x03, 0x66, 0x6f, // r.fo | 2786 0x72, 0x03, 0x66, 0x6f, // r.fo |
2768 0x6f, 0x40, 0x03, 0x66, // o@.f | 2787 0x6f, 0x40, 0x03, 0x66, // o@.f |
2769 0x6f, 0x6f, 0x03, 0x62, // oo.b | 2788 0x6f, 0x6f, 0x03, 0x62, // oo.b |
2770 0x61, 0x72, // ar | 2789 0x61, 0x72, // ar |
2771 }; | 2790 }; |
2772 | 2791 |
2773 SpdyPushPromiseIR push_promise(42, 57); | 2792 SpdyPushPromiseIR push_promise(42, 57); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 const unsigned char length = 1 + SpdyFramer::kControlFrameBufferSize; | 3039 const unsigned char length = 1 + SpdyFramer::kControlFrameBufferSize; |
3021 const unsigned char kV3FrameData[] = { // Also applies for V2. | 3040 const unsigned char kV3FrameData[] = { // Also applies for V2. |
3022 0x80, spdy_version_ch_, 0x00, 0x07, | 3041 0x80, spdy_version_ch_, 0x00, 0x07, |
3023 0x00, 0x00, 0x00, length, | 3042 0x00, 0x00, 0x00, length, |
3024 0x00, 0x00, 0x00, 0x00, // Stream ID | 3043 0x00, 0x00, 0x00, 0x00, // Stream ID |
3025 0x00, 0x00, 0x00, 0x00, // Status | 3044 0x00, 0x00, 0x00, 0x00, // Status |
3026 }; | 3045 }; |
3027 | 3046 |
3028 // SPDY version 4 and up GOAWAY frames are only bound to a minimal length, | 3047 // SPDY version 4 and up GOAWAY frames are only bound to a minimal length, |
3029 // since it may carry opaque data. Verify that minimal length is tested. | 3048 // since it may carry opaque data. Verify that minimal length is tested. |
3030 const unsigned char less_than_min_length = framer.GetGoAwayMinimumSize() - 1; | 3049 const unsigned char less_than_min_length = |
| 3050 framer.GetGoAwayMinimumSize() - framer.GetControlFrameHeaderSize() - 1; |
3031 const unsigned char kV4FrameData[] = { | 3051 const unsigned char kV4FrameData[] = { |
3032 0x00, static_cast<uint8>(less_than_min_length), 0x07, 0x00, | 3052 0x00, static_cast<uint8>(less_than_min_length), 0x07, 0x00, |
3033 0x00, 0x00, 0x00, 0x00, | 3053 0x00, 0x00, 0x00, 0x00, |
3034 0x00, 0x00, 0x00, 0x00, // Stream Id | 3054 0x00, 0x00, 0x00, 0x00, // Stream Id |
3035 0x00, 0x00, 0x00, 0x00, // Status | 3055 0x00, 0x00, 0x00, 0x00, // Status |
3036 }; | 3056 }; |
3037 const size_t pad_length = | 3057 const size_t pad_length = |
3038 length + framer.GetControlFrameHeaderSize() - | 3058 length + framer.GetControlFrameHeaderSize() - |
3039 (IsSpdy4() ? sizeof(kV4FrameData) : sizeof(kV3FrameData)); | 3059 (IsSpdy4() ? sizeof(kV4FrameData) : sizeof(kV3FrameData)); |
3040 string pad('A', pad_length); | 3060 string pad('A', pad_length); |
(...skipping 18 matching lines...) Expand all Loading... |
3059 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { | 3079 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { |
3060 SpdyFramer framer(spdy_version_); | 3080 SpdyFramer framer(spdy_version_); |
3061 SpdySettingsIR settings_ir; | 3081 SpdySettingsIR settings_ir; |
3062 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); | 3082 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); |
3063 SetFrameLength(control_frame.get(), 0, spdy_version_); | 3083 SetFrameLength(control_frame.get(), 0, spdy_version_); |
3064 TestSpdyVisitor visitor(spdy_version_); | 3084 TestSpdyVisitor visitor(spdy_version_); |
3065 visitor.use_compression_ = false; | 3085 visitor.use_compression_ = false; |
3066 visitor.SimulateInFramer( | 3086 visitor.SimulateInFramer( |
3067 reinterpret_cast<unsigned char*>(control_frame->data()), | 3087 reinterpret_cast<unsigned char*>(control_frame->data()), |
3068 framer.GetControlFrameHeaderSize()); | 3088 framer.GetControlFrameHeaderSize()); |
3069 // Should generate an error, since zero-len settings frames are unsupported. | 3089 if (spdy_version_ < 4) { |
3070 EXPECT_EQ(1, visitor.error_count_); | 3090 // Should generate an error, since zero-len settings frames are unsupported. |
| 3091 EXPECT_EQ(1, visitor.error_count_); |
| 3092 } else { |
| 3093 // Zero-len settings frames are permitted as of SPDY 4. |
| 3094 EXPECT_EQ(0, visitor.error_count_); |
| 3095 } |
3071 } | 3096 } |
3072 | 3097 |
3073 // Tests handling of SETTINGS frames with invalid length. | 3098 // Tests handling of SETTINGS frames with invalid length. |
3074 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { | 3099 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { |
3075 SpdyFramer framer(spdy_version_); | 3100 SpdyFramer framer(spdy_version_); |
3076 SpdySettingsIR settings_ir; | 3101 SpdySettingsIR settings_ir; |
3077 | 3102 |
3078 // Add a setting to pad the frame so that we don't get a buffer overflow when | 3103 // Add a setting to pad the frame so that we don't get a buffer overflow when |
3079 // calling SimulateInFramer() below. | 3104 // calling SimulateInFramer() below. |
3080 SettingsMap settings; | 3105 settings_ir.AddSetting(SETTINGS_INITIAL_WINDOW_SIZE, |
3081 settings[SETTINGS_UPLOAD_BANDWIDTH] = | 3106 false, |
3082 SettingsFlagsAndValue(SETTINGS_FLAG_PLEASE_PERSIST, 0x00000002); | |
3083 settings_ir.AddSetting(SETTINGS_UPLOAD_BANDWIDTH, | |
3084 true, // please persist | |
3085 false, | 3107 false, |
3086 0x00000002); | 3108 0x00000002); |
3087 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); | 3109 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); |
3088 const size_t kNewLength = 14; | 3110 const size_t kNewLength = 14; |
3089 SetFrameLength(control_frame.get(), kNewLength, spdy_version_); | 3111 SetFrameLength(control_frame.get(), kNewLength, spdy_version_); |
3090 TestSpdyVisitor visitor(spdy_version_); | 3112 TestSpdyVisitor visitor(spdy_version_); |
3091 visitor.use_compression_ = false; | 3113 visitor.use_compression_ = false; |
3092 visitor.SimulateInFramer( | 3114 visitor.SimulateInFramer( |
3093 reinterpret_cast<unsigned char*>(control_frame->data()), | 3115 reinterpret_cast<unsigned char*>(control_frame->data()), |
3094 framer.GetControlFrameHeaderSize() + kNewLength); | 3116 framer.GetControlFrameHeaderSize() + kNewLength); |
3095 // Should generate an error, since its not possible to have a | 3117 // Should generate an error, since its not possible to have a |
3096 // settings frame of length kNewLength. | 3118 // settings frame of length kNewLength. |
3097 EXPECT_EQ(1, visitor.error_count_); | 3119 EXPECT_EQ(1, visitor.error_count_); |
3098 } | 3120 } |
3099 | 3121 |
3100 // Tests handling of SETTINGS frames larger than the frame buffer size. | 3122 // Tests handling of SETTINGS frames larger than the frame buffer size. |
3101 TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { | 3123 TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { |
3102 SpdyFramer framer(spdy_version_); | 3124 SpdyFramer framer(spdy_version_); |
3103 SpdySettingsIR settings_ir; | 3125 SpdySettingsIR settings_ir; |
3104 SettingsMap settings; | 3126 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 1), |
3105 | 3127 false, // persist |
3106 SpdySettingsFlags flags = SETTINGS_FLAG_PLEASE_PERSIST; | 3128 false, // persisted |
3107 settings[SETTINGS_UPLOAD_BANDWIDTH] = | 3129 5); |
3108 SettingsFlagsAndValue(flags, 0x00000002); | 3130 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 2), |
3109 settings[SETTINGS_DOWNLOAD_BANDWIDTH] = | 3131 false, // persist |
3110 SettingsFlagsAndValue(flags, 0x00000003); | 3132 false, // persisted |
3111 settings[SETTINGS_ROUND_TRIP_TIME] = SettingsFlagsAndValue(flags, 0x00000004); | 3133 6); |
3112 for (SettingsMap::const_iterator it = settings.begin(); | 3134 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 3), |
3113 it != settings.end(); | 3135 false, // persist |
3114 ++it) { | 3136 false, // persisted |
3115 settings_ir.AddSetting(it->first, | 3137 7); |
3116 it->second.first & SETTINGS_FLAG_PLEASE_PERSIST, | |
3117 it->second.first & SETTINGS_FLAG_PERSISTED, | |
3118 it->second.second); | |
3119 } | |
3120 | 3138 |
3121 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); | 3139 scoped_ptr<SpdyFrame> control_frame(framer.SerializeSettings(settings_ir)); |
3122 EXPECT_LT(SpdyFramer::kControlFrameBufferSize, | 3140 EXPECT_LT(SpdyFramer::kControlFrameBufferSize, |
3123 control_frame->size()); | 3141 control_frame->size()); |
3124 TestSpdyVisitor visitor(spdy_version_); | 3142 TestSpdyVisitor visitor(spdy_version_); |
3125 visitor.use_compression_ = false; | 3143 visitor.use_compression_ = false; |
3126 | 3144 |
3127 // Read all at once. | 3145 // Read all at once. |
3128 visitor.SimulateInFramer( | 3146 visitor.SimulateInFramer( |
3129 reinterpret_cast<unsigned char*>(control_frame->data()), | 3147 reinterpret_cast<unsigned char*>(control_frame->data()), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3173 0x00, 0x00, 0x00, 0x1C, | 3191 0x00, 0x00, 0x00, 0x1C, |
3174 0x00, 0x00, 0x00, 0x03, | 3192 0x00, 0x00, 0x00, 0x03, |
3175 0x00, 0x00, 0x00, 0x01, // 1st Setting | 3193 0x00, 0x00, 0x00, 0x01, // 1st Setting |
3176 0x00, 0x00, 0x00, 0x02, | 3194 0x00, 0x00, 0x00, 0x02, |
3177 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting | 3195 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting |
3178 0x00, 0x00, 0x00, 0x03, | 3196 0x00, 0x00, 0x00, 0x03, |
3179 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting | 3197 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting |
3180 0x00, 0x00, 0x00, 0x03, | 3198 0x00, 0x00, 0x00, 0x03, |
3181 }; | 3199 }; |
3182 const unsigned char kV4FrameData[] = { | 3200 const unsigned char kV4FrameData[] = { |
3183 0x00, 0x17, 0x04, 0x00, | 3201 0x00, 0x0f, 0x04, 0x00, |
3184 0x00, 0x00, 0x00, 0x00, | 3202 0x00, 0x00, 0x00, 0x00, |
3185 0x01, // 1st Setting | 3203 0x01, // 1st Setting |
3186 0x00, 0x00, 0x00, 0x02, | 3204 0x00, 0x00, 0x00, 0x02, |
3187 0x01, // 2nd (duplicate) Setting | 3205 0x01, // 2nd (duplicate) Setting |
3188 0x00, 0x00, 0x00, 0x03, | 3206 0x00, 0x00, 0x00, 0x03, |
3189 0x03, // 3rd (unprocessed) Setting | 3207 0x03, // 3rd (unprocessed) Setting |
3190 0x00, 0x00, 0x00, 0x03, | 3208 0x00, 0x00, 0x00, 0x03, |
3191 }; | 3209 }; |
3192 | 3210 |
3193 TestSpdyVisitor visitor(spdy_version_); | 3211 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3232 0x00, 0x00, 0x00, 0x1C, | 3250 0x00, 0x00, 0x00, 0x1C, |
3233 0x00, 0x00, 0x00, 0x03, | 3251 0x00, 0x00, 0x00, 0x03, |
3234 0x00, 0x00, 0x00, 0x02, // 1st Setting | 3252 0x00, 0x00, 0x00, 0x02, // 1st Setting |
3235 0x00, 0x00, 0x00, 0x02, | 3253 0x00, 0x00, 0x00, 0x02, |
3236 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting | 3254 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting |
3237 0x00, 0x00, 0x00, 0x03, | 3255 0x00, 0x00, 0x00, 0x03, |
3238 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting | 3256 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting |
3239 0x00, 0x00, 0x00, 0x03, | 3257 0x00, 0x00, 0x00, 0x03, |
3240 }; | 3258 }; |
3241 const unsigned char kV4FrameData[] = { | 3259 const unsigned char kV4FrameData[] = { |
3242 0x00, 0x17, 0x04, 0x00, | 3260 0x00, 0x0f, 0x04, 0x00, |
3243 0x00, 0x00, 0x00, 0x00, | 3261 0x00, 0x00, 0x00, 0x00, |
3244 0x02, // 1st Setting | 3262 0x02, // 1st Setting |
3245 0x00, 0x00, 0x00, 0x02, | 3263 0x00, 0x00, 0x00, 0x02, |
3246 0x01, // 2nd (out of order) Setting | 3264 0x01, // 2nd (out of order) Setting |
3247 0x00, 0x00, 0x00, 0x03, | 3265 0x00, 0x00, 0x00, 0x03, |
3248 0x03, // 3rd (unprocessed) Setting | 3266 0x03, // 3rd (unprocessed) Setting |
3249 0x00, 0x00, 0x00, 0x03, | 3267 0x00, 0x00, 0x00, 0x03, |
3250 }; | 3268 }; |
3251 | 3269 |
3252 TestSpdyVisitor visitor(spdy_version_); | 3270 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 17 matching lines...) Expand all Loading... |
3270 } | 3288 } |
3271 } | 3289 } |
3272 | 3290 |
3273 TEST_P(SpdyFramerTest, ProcessSettingsAckFrame) { | 3291 TEST_P(SpdyFramerTest, ProcessSettingsAckFrame) { |
3274 if (spdy_version_ < 4) { | 3292 if (spdy_version_ < 4) { |
3275 return; | 3293 return; |
3276 } | 3294 } |
3277 SpdyFramer framer(spdy_version_); | 3295 SpdyFramer framer(spdy_version_); |
3278 | 3296 |
3279 const unsigned char kFrameData[] = { | 3297 const unsigned char kFrameData[] = { |
3280 0x00, 0x08, 0x04, 0x01, | 3298 0x00, 0x00, 0x04, 0x01, |
3281 0x00, 0x00, 0x00, 0x00, | 3299 0x00, 0x00, 0x00, 0x00, |
3282 }; | 3300 }; |
3283 | 3301 |
3284 TestSpdyVisitor visitor(spdy_version_); | 3302 TestSpdyVisitor visitor(spdy_version_); |
3285 visitor.use_compression_ = false; | 3303 visitor.use_compression_ = false; |
3286 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 3304 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
3287 | 3305 |
3288 EXPECT_EQ(0, visitor.error_count_); | 3306 EXPECT_EQ(0, visitor.error_count_); |
3289 EXPECT_EQ(0, visitor.setting_count_); | 3307 EXPECT_EQ(0, visitor.setting_count_); |
3290 EXPECT_EQ(1, visitor.settings_ack_received_); | 3308 EXPECT_EQ(1, visitor.settings_ack_received_); |
3291 } | 3309 } |
3292 | 3310 |
| 3311 |
| 3312 TEST_P(SpdyFramerTest, ProcessDataFrameWithPadding) { |
| 3313 if (spdy_version_ < 4) { |
| 3314 return; |
| 3315 } |
| 3316 |
| 3317 const int kPaddingLen = 512; // So we get two bytes for padding length field. |
| 3318 const char data_payload[] = "hello"; |
| 3319 |
| 3320 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
| 3321 SpdyFramer framer(spdy_version_); |
| 3322 framer.set_visitor(&visitor); |
| 3323 |
| 3324 SpdyDataIR data_ir(1, StringPiece(data_payload, strlen(data_payload))); |
| 3325 data_ir.set_padding_len(kPaddingLen); |
| 3326 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 3327 ASSERT_TRUE(frame.get() != NULL); |
| 3328 |
| 3329 int bytes_consumed = 0; |
| 3330 |
| 3331 // Send the frame header. |
| 3332 EXPECT_CALL(visitor, OnDataFrameHeader(1, |
| 3333 kPaddingLen + strlen(data_payload), |
| 3334 false)); |
| 3335 CHECK_EQ(8u, framer.ProcessInput(frame->data(), 8)); |
| 3336 CHECK_EQ(framer.state(), SpdyFramer::SPDY_READ_PADDING_LENGTH); |
| 3337 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3338 bytes_consumed += 8; |
| 3339 |
| 3340 // Send the first byte of the padding length field. |
| 3341 CHECK_EQ(1u, framer.ProcessInput(frame->data() + bytes_consumed, 1)); |
| 3342 CHECK_EQ(framer.state(), SpdyFramer::SPDY_READ_PADDING_LENGTH); |
| 3343 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3344 bytes_consumed += 1; |
| 3345 |
| 3346 // Send the second byte of the padding length field. |
| 3347 CHECK_EQ(1u, framer.ProcessInput(frame->data() + bytes_consumed, 1)); |
| 3348 CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME); |
| 3349 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3350 bytes_consumed += 1; |
| 3351 |
| 3352 // Send the first two bytes of the data payload. |
| 3353 EXPECT_CALL(visitor, OnStreamFrameData(1, _, 2, false)); |
| 3354 CHECK_EQ(2u, framer.ProcessInput(frame->data() + bytes_consumed, 2)); |
| 3355 CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME); |
| 3356 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3357 bytes_consumed += 2; |
| 3358 |
| 3359 // Send the rest three bytes of the data payload. |
| 3360 EXPECT_CALL(visitor, OnStreamFrameData(1, _, 3, false)); |
| 3361 CHECK_EQ(3u, framer.ProcessInput(frame->data() + bytes_consumed, 3)); |
| 3362 CHECK_EQ(framer.state(), SpdyFramer::SPDY_CONSUME_PADDING); |
| 3363 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3364 bytes_consumed += 3; |
| 3365 |
| 3366 // Send the first 100 bytes of the padding payload. |
| 3367 EXPECT_CALL(visitor, OnStreamFrameData(1, NULL, 100, false)); |
| 3368 CHECK_EQ(100u, framer.ProcessInput(frame->data() + bytes_consumed, 100)); |
| 3369 CHECK_EQ(framer.state(), SpdyFramer::SPDY_CONSUME_PADDING); |
| 3370 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3371 bytes_consumed += 100; |
| 3372 |
| 3373 // Send rest of the padding payload. |
| 3374 EXPECT_CALL(visitor, OnStreamFrameData(1, NULL, 410, false)); |
| 3375 CHECK_EQ(410u, framer.ProcessInput(frame->data() + bytes_consumed, 410)); |
| 3376 CHECK_EQ(framer.state(), SpdyFramer::SPDY_RESET); |
| 3377 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3378 } |
| 3379 |
3293 TEST_P(SpdyFramerTest, ReadWindowUpdate) { | 3380 TEST_P(SpdyFramerTest, ReadWindowUpdate) { |
3294 SpdyFramer framer(spdy_version_); | 3381 SpdyFramer framer(spdy_version_); |
3295 scoped_ptr<SpdyFrame> control_frame( | 3382 scoped_ptr<SpdyFrame> control_frame( |
3296 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 2))); | 3383 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 2))); |
3297 TestSpdyVisitor visitor(spdy_version_); | 3384 TestSpdyVisitor visitor(spdy_version_); |
3298 visitor.SimulateInFramer( | 3385 visitor.SimulateInFramer( |
3299 reinterpret_cast<unsigned char*>(control_frame->data()), | 3386 reinterpret_cast<unsigned char*>(control_frame->data()), |
3300 control_frame->size()); | 3387 control_frame->size()); |
3301 EXPECT_EQ(1u, visitor.last_window_update_stream_); | 3388 EXPECT_EQ(1u, visitor.last_window_update_stream_); |
3302 EXPECT_EQ(2u, visitor.last_window_update_delta_); | 3389 EXPECT_EQ(2u, visitor.last_window_update_delta_); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3371 TEST_P(SpdyFramerTest, CreateContinuation) { | 3458 TEST_P(SpdyFramerTest, CreateContinuation) { |
3372 if (spdy_version_ < SPDY4) { | 3459 if (spdy_version_ < SPDY4) { |
3373 return; | 3460 return; |
3374 } | 3461 } |
3375 | 3462 |
3376 SpdyFramer framer(spdy_version_); | 3463 SpdyFramer framer(spdy_version_); |
3377 | 3464 |
3378 const char kDescription[] = "CONTINUATION frame"; | 3465 const char kDescription[] = "CONTINUATION frame"; |
3379 | 3466 |
3380 const unsigned char kFrameData[] = { | 3467 const unsigned char kFrameData[] = { |
3381 0x00, 0x1a, 0x0d, 0x00, // CONTINUATION | 3468 0x00, 0x12, 0x09, 0x00, // CONTINUATION |
3382 0x00, 0x00, 0x00, 0x2a, // Stream 42 | 3469 0x00, 0x00, 0x00, 0x2a, // Stream 42 |
3383 0x40, 0x03, 0x62, 0x61, // @.ba | 3470 0x40, 0x03, 0x62, 0x61, // @.ba |
3384 0x72, 0x03, 0x66, 0x6f, // r.fo | 3471 0x72, 0x03, 0x66, 0x6f, // r.fo |
3385 0x6f, 0x40, 0x03, 0x66, // o@.f | 3472 0x6f, 0x40, 0x03, 0x66, // o@.f |
3386 0x6f, 0x6f, 0x03, 0x62, // oo.b | 3473 0x6f, 0x6f, 0x03, 0x62, // oo.b |
3387 0x61, 0x72, // ar | 3474 0x61, 0x72, // ar |
3388 }; | 3475 }; |
3389 | 3476 |
3390 SpdyContinuationIR continuation(42); | 3477 SpdyContinuationIR continuation(42); |
3391 continuation.SetHeader("bar", "foo"); | 3478 continuation.SetHeader("bar", "foo"); |
(...skipping 25 matching lines...) Expand all Loading... |
3417 EXPECT_EQ(57u, visitor.last_push_promise_promised_stream_); | 3504 EXPECT_EQ(57u, visitor.last_push_promise_promised_stream_); |
3418 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); | 3505 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); |
3419 } | 3506 } |
3420 | 3507 |
3421 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) { | 3508 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) { |
3422 if (spdy_version_ < 4) { | 3509 if (spdy_version_ < 4) { |
3423 return; | 3510 return; |
3424 } | 3511 } |
3425 | 3512 |
3426 const unsigned char kInput[] = { | 3513 const unsigned char kInput[] = { |
3427 0x00, 0x18, 0x08, 0x00, // HEADERS | 3514 0x00, 0x10, 0x01, 0x00, // HEADERS |
3428 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3515 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3429 0x40, 0x06, 0x43, 0x6f, | 3516 0x40, 0x06, 0x43, 0x6f, |
3430 0x6f, 0x6b, 0x69, 0x65, | 3517 0x6f, 0x6b, 0x69, 0x65, |
3431 0x07, 0x66, 0x6f, 0x6f, | 3518 0x07, 0x66, 0x6f, 0x6f, |
3432 0x3d, 0x62, 0x61, 0x72, | 3519 0x3d, 0x62, 0x61, 0x72, |
3433 | 3520 |
3434 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3521 0x00, 0x14, 0x09, 0x00, // CONTINUATION |
3435 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3522 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3436 0x40, 0x06, 0x43, 0x6f, | 3523 0x40, 0x06, 0x43, 0x6f, |
3437 0x6f, 0x6b, 0x69, 0x65, | 3524 0x6f, 0x6b, 0x69, 0x65, |
3438 0x08, 0x62, 0x61, 0x7a, | 3525 0x08, 0x62, 0x61, 0x7a, |
3439 0x3d, 0x62, 0x69, 0x6e, | 3526 0x3d, 0x62, 0x69, 0x6e, |
3440 0x67, 0x40, 0x06, 0x43, | 3527 0x67, 0x40, 0x06, 0x43, |
3441 | 3528 |
3442 0x00, 0x1a, 0x0D, 0x04, // CONTINUATION: END_HEADERS | 3529 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS |
3443 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3530 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3444 0x6f, 0x6f, 0x6b, 0x69, | 3531 0x6f, 0x6f, 0x6b, 0x69, |
3445 0x65, 0x00, 0x40, 0x04, | 3532 0x65, 0x00, 0x40, 0x04, |
3446 0x6e, 0x61, 0x6d, 0x65, | 3533 0x6e, 0x61, 0x6d, 0x65, |
3447 0x05, 0x76, 0x61, 0x6c, | 3534 0x05, 0x76, 0x61, 0x6c, |
3448 0x75, 0x65, | 3535 0x75, 0x65, |
3449 }; | 3536 }; |
3450 | 3537 |
3451 SpdyFramer framer(spdy_version_); | 3538 SpdyFramer framer(spdy_version_); |
3452 TestSpdyVisitor visitor(spdy_version_); | 3539 TestSpdyVisitor visitor(spdy_version_); |
3453 visitor.SimulateInFramer(kInput, sizeof(kInput)); | 3540 visitor.SimulateInFramer(kInput, sizeof(kInput)); |
3454 | 3541 |
3455 EXPECT_EQ(0, visitor.error_count_); | 3542 EXPECT_EQ(0, visitor.error_count_); |
3456 EXPECT_EQ(1, visitor.headers_frame_count_); | 3543 EXPECT_EQ(1, visitor.headers_frame_count_); |
3457 EXPECT_EQ(2, visitor.continuation_count_); | 3544 EXPECT_EQ(2, visitor.continuation_count_); |
3458 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); | 3545 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
3459 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); | 3546 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); |
3460 | 3547 |
3461 EXPECT_THAT(visitor.headers_, ElementsAre( | 3548 EXPECT_THAT(visitor.headers_, ElementsAre( |
3462 Pair("Cookie", "foo=bar; baz=bing; "), | 3549 Pair("Cookie", "foo=bar; baz=bing; "), |
3463 Pair("name", "value"))); | 3550 Pair("name", "value"))); |
3464 } | 3551 } |
3465 | 3552 |
3466 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) { | 3553 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) { |
3467 if (spdy_version_ < 4) { | 3554 if (spdy_version_ < 4) { |
3468 return; | 3555 return; |
3469 } | 3556 } |
3470 | 3557 |
3471 const unsigned char kInput[] = { | 3558 const unsigned char kInput[] = { |
3472 0x00, 0x18, 0x08, 0x01, // HEADERS: FIN | 3559 0x00, 0x10, 0x01, 0x01, // HEADERS: FIN |
3473 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3560 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3474 0x40, 0x06, 0x43, 0x6f, | 3561 0x40, 0x06, 0x43, 0x6f, |
3475 0x6f, 0x6b, 0x69, 0x65, | 3562 0x6f, 0x6b, 0x69, 0x65, |
3476 0x07, 0x66, 0x6f, 0x6f, | 3563 0x07, 0x66, 0x6f, 0x6f, |
3477 0x3d, 0x62, 0x61, 0x72, | 3564 0x3d, 0x62, 0x61, 0x72, |
3478 | 3565 |
3479 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3566 0x00, 0x14, 0x09, 0x00, // CONTINUATION |
3480 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3567 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3481 0x40, 0x06, 0x43, 0x6f, | 3568 0x40, 0x06, 0x43, 0x6f, |
3482 0x6f, 0x6b, 0x69, 0x65, | 3569 0x6f, 0x6b, 0x69, 0x65, |
3483 0x08, 0x62, 0x61, 0x7a, | 3570 0x08, 0x62, 0x61, 0x7a, |
3484 0x3d, 0x62, 0x69, 0x6e, | 3571 0x3d, 0x62, 0x69, 0x6e, |
3485 0x67, 0x40, 0x06, 0x43, | 3572 0x67, 0x40, 0x06, 0x43, |
3486 | 3573 |
3487 0x00, 0x1a, 0x0D, 0x04, // CONTINUATION: END_HEADERS | 3574 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS |
3488 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3575 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3489 0x6f, 0x6f, 0x6b, 0x69, | 3576 0x6f, 0x6f, 0x6b, 0x69, |
3490 0x65, 0x00, 0x40, 0x04, | 3577 0x65, 0x00, 0x40, 0x04, |
3491 0x6e, 0x61, 0x6d, 0x65, | 3578 0x6e, 0x61, 0x6d, 0x65, |
3492 0x05, 0x76, 0x61, 0x6c, | 3579 0x05, 0x76, 0x61, 0x6c, |
3493 0x75, 0x65, | 3580 0x75, 0x65, |
3494 }; | 3581 }; |
3495 | 3582 |
3496 SpdyFramer framer(spdy_version_); | 3583 SpdyFramer framer(spdy_version_); |
3497 TestSpdyVisitor visitor(spdy_version_); | 3584 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 10 matching lines...) Expand all Loading... |
3508 Pair("Cookie", "foo=bar; baz=bing; "), | 3595 Pair("Cookie", "foo=bar; baz=bing; "), |
3509 Pair("name", "value"))); | 3596 Pair("name", "value"))); |
3510 } | 3597 } |
3511 | 3598 |
3512 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) { | 3599 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) { |
3513 if (spdy_version_ < 4) { | 3600 if (spdy_version_ < 4) { |
3514 return; | 3601 return; |
3515 } | 3602 } |
3516 | 3603 |
3517 const unsigned char kInput[] = { | 3604 const unsigned char kInput[] = { |
3518 0x00, 0x1c, 0x0C, 0x00, // PUSH_PROMISE | 3605 0x00, 0x14, 0x05, 0x00, // PUSH_PROMISE |
3519 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3606 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3520 0x00, 0x00, 0x00, 0x2A, // Promised stream 42 | 3607 0x00, 0x00, 0x00, 0x2A, // Promised stream 42 |
3521 0x40, 0x06, 0x43, 0x6f, | 3608 0x40, 0x06, 0x43, 0x6f, |
3522 0x6f, 0x6b, 0x69, 0x65, | 3609 0x6f, 0x6b, 0x69, 0x65, |
3523 0x07, 0x66, 0x6f, 0x6f, | 3610 0x07, 0x66, 0x6f, 0x6f, |
3524 0x3d, 0x62, 0x61, 0x72, | 3611 0x3d, 0x62, 0x61, 0x72, |
3525 | 3612 |
3526 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3613 0x00, 0x14, 0x09, 0x00, // CONTINUATION |
3527 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3614 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3528 0x40, 0x06, 0x43, 0x6f, | 3615 0x40, 0x06, 0x43, 0x6f, |
3529 0x6f, 0x6b, 0x69, 0x65, | 3616 0x6f, 0x6b, 0x69, 0x65, |
3530 0x08, 0x62, 0x61, 0x7a, | 3617 0x08, 0x62, 0x61, 0x7a, |
3531 0x3d, 0x62, 0x69, 0x6e, | 3618 0x3d, 0x62, 0x69, 0x6e, |
3532 0x67, 0x40, 0x06, 0x43, | 3619 0x67, 0x40, 0x06, 0x43, |
3533 | 3620 |
3534 0x00, 0x1a, 0x0D, 0x04, // CONTINUATION: END_HEADERS | 3621 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS |
3535 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3622 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3536 0x6f, 0x6f, 0x6b, 0x69, | 3623 0x6f, 0x6f, 0x6b, 0x69, |
3537 0x65, 0x00, 0x40, 0x04, | 3624 0x65, 0x00, 0x40, 0x04, |
3538 0x6e, 0x61, 0x6d, 0x65, | 3625 0x6e, 0x61, 0x6d, 0x65, |
3539 0x05, 0x76, 0x61, 0x6c, | 3626 0x05, 0x76, 0x61, 0x6c, |
3540 0x75, 0x65, | 3627 0x75, 0x65, |
3541 }; | 3628 }; |
3542 | 3629 |
3543 SpdyFramer framer(spdy_version_); | 3630 SpdyFramer framer(spdy_version_); |
3544 TestSpdyVisitor visitor(spdy_version_); | 3631 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 10 matching lines...) Expand all Loading... |
3555 Pair("Cookie", "foo=bar; baz=bing; "), | 3642 Pair("Cookie", "foo=bar; baz=bing; "), |
3556 Pair("name", "value"))); | 3643 Pair("name", "value"))); |
3557 } | 3644 } |
3558 | 3645 |
3559 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) { | 3646 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) { |
3560 if (spdy_version_ < 4) { | 3647 if (spdy_version_ < 4) { |
3561 return; | 3648 return; |
3562 } | 3649 } |
3563 | 3650 |
3564 const unsigned char kInput[] = { | 3651 const unsigned char kInput[] = { |
3565 0x00, 0x18, 0x08, 0x00, // HEADERS | 3652 0x00, 0x10, 0x01, 0x00, // HEADERS |
3566 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3653 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3567 0x40, 0x06, 0x43, 0x6f, | 3654 0x40, 0x06, 0x43, 0x6f, |
3568 0x6f, 0x6b, 0x69, 0x65, | 3655 0x6f, 0x6b, 0x69, 0x65, |
3569 0x07, 0x66, 0x6f, 0x6f, | 3656 0x07, 0x66, 0x6f, 0x6f, |
3570 0x3d, 0x62, 0x61, 0x72, | 3657 0x3d, 0x62, 0x61, 0x72, |
3571 | 3658 |
3572 0x00, 0x1c, 0x0D, 0x00, // CONTINUATION | 3659 0x00, 0x14, 0x09, 0x00, // CONTINUATION |
3573 0x00, 0x00, 0x00, 0x02, // Stream 2 | 3660 0x00, 0x00, 0x00, 0x02, // Stream 2 |
3574 0x40, 0x06, 0x43, 0x6f, | 3661 0x40, 0x06, 0x43, 0x6f, |
3575 0x6f, 0x6b, 0x69, 0x65, | 3662 0x6f, 0x6b, 0x69, 0x65, |
3576 0x08, 0x62, 0x61, 0x7a, | 3663 0x08, 0x62, 0x61, 0x7a, |
3577 0x3d, 0x62, 0x69, 0x6e, | 3664 0x3d, 0x62, 0x69, 0x6e, |
3578 0x67, 0x40, 0x06, 0x43, | 3665 0x67, 0x40, 0x06, 0x43, |
3579 }; | 3666 }; |
3580 | 3667 |
3581 SpdyFramer framer(spdy_version_); | 3668 SpdyFramer framer(spdy_version_); |
3582 TestSpdyVisitor visitor(spdy_version_); | 3669 TestSpdyVisitor visitor(spdy_version_); |
3583 framer.set_visitor(&visitor); | 3670 framer.set_visitor(&visitor); |
3584 visitor.SimulateInFramer(kInput, sizeof(kInput)); | 3671 visitor.SimulateInFramer(kInput, sizeof(kInput)); |
3585 | 3672 |
3586 EXPECT_EQ(1, visitor.error_count_); | 3673 EXPECT_EQ(1, visitor.error_count_); |
3587 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 3674 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
3588 visitor.framer_.error_code()) | 3675 visitor.framer_.error_code()) |
3589 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3676 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3590 EXPECT_EQ(1, visitor.headers_frame_count_); | 3677 EXPECT_EQ(1, visitor.headers_frame_count_); |
3591 EXPECT_EQ(0, visitor.continuation_count_); | 3678 EXPECT_EQ(0, visitor.continuation_count_); |
3592 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3679 EXPECT_EQ(0u, visitor.header_buffer_length_); |
3593 } | 3680 } |
3594 | 3681 |
3595 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) { | 3682 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) { |
3596 if (spdy_version_ < 4) { | 3683 if (spdy_version_ < 4) { |
3597 return; | 3684 return; |
3598 } | 3685 } |
3599 | 3686 |
3600 const unsigned char kInput[] = { | 3687 const unsigned char kInput[] = { |
3601 0x00, 0x18, 0x0D, 0x00, // CONTINUATION | 3688 0x00, 0x10, 0x09, 0x00, // CONTINUATION |
3602 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3689 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3603 0x40, 0x06, 0x43, 0x6f, | 3690 0x40, 0x06, 0x43, 0x6f, |
3604 0x6f, 0x6b, 0x69, 0x65, | 3691 0x6f, 0x6b, 0x69, 0x65, |
3605 0x07, 0x66, 0x6f, 0x6f, | 3692 0x07, 0x66, 0x6f, 0x6f, |
3606 0x3d, 0x62, 0x61, 0x72, | 3693 0x3d, 0x62, 0x61, 0x72, |
3607 }; | 3694 }; |
3608 | 3695 |
3609 SpdyFramer framer(spdy_version_); | 3696 SpdyFramer framer(spdy_version_); |
3610 TestSpdyVisitor visitor(spdy_version_); | 3697 TestSpdyVisitor visitor(spdy_version_); |
3611 framer.set_visitor(&visitor); | 3698 framer.set_visitor(&visitor); |
3612 visitor.SimulateInFramer(kInput, sizeof(kInput)); | 3699 visitor.SimulateInFramer(kInput, sizeof(kInput)); |
3613 | 3700 |
3614 EXPECT_EQ(1, visitor.error_count_); | 3701 EXPECT_EQ(1, visitor.error_count_); |
3615 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME, | 3702 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME, |
3616 visitor.framer_.error_code()) | 3703 visitor.framer_.error_code()) |
3617 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3704 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3618 EXPECT_EQ(0, visitor.continuation_count_); | 3705 EXPECT_EQ(0, visitor.continuation_count_); |
3619 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3706 EXPECT_EQ(0u, visitor.header_buffer_length_); |
3620 } | 3707 } |
3621 | 3708 |
3622 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) { | 3709 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) { |
3623 if (spdy_version_ < 4) { | 3710 if (spdy_version_ < 4) { |
3624 return; | 3711 return; |
3625 } | 3712 } |
3626 | 3713 |
3627 const unsigned char kInput[] = { | 3714 const unsigned char kInput[] = { |
3628 0x00, 0x18, 0x08, 0x00, // HEADERS | 3715 0x00, 0x10, 0x01, 0x00, // HEADERS |
3629 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3716 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3630 0x40, 0x06, 0x43, 0x6f, | 3717 0x40, 0x06, 0x43, 0x6f, |
3631 0x6f, 0x6b, 0x69, 0x65, | 3718 0x6f, 0x6b, 0x69, 0x65, |
3632 0x07, 0x66, 0x6f, 0x6f, | 3719 0x07, 0x66, 0x6f, 0x6f, |
3633 0x3d, 0x62, 0x61, 0x72, | 3720 0x3d, 0x62, 0x61, 0x72, |
3634 | 3721 |
3635 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 | 3722 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 |
3636 0x00, 0x00, 0x00, 0x04, | 3723 0x00, 0x00, 0x00, 0x04, |
3637 0xde, 0xad, 0xbe, 0xef, | 3724 0xde, 0xad, 0xbe, 0xef, |
3638 }; | 3725 }; |
(...skipping 12 matching lines...) Expand all Loading... |
3651 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3738 EXPECT_EQ(0u, visitor.header_buffer_length_); |
3652 EXPECT_EQ(0, visitor.data_frame_count_); | 3739 EXPECT_EQ(0, visitor.data_frame_count_); |
3653 } | 3740 } |
3654 | 3741 |
3655 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) { | 3742 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) { |
3656 if (spdy_version_ < 4) { | 3743 if (spdy_version_ < 4) { |
3657 return; | 3744 return; |
3658 } | 3745 } |
3659 | 3746 |
3660 const unsigned char kInput[] = { | 3747 const unsigned char kInput[] = { |
3661 0x00, 0x18, 0x08, 0x00, // HEADERS | 3748 0x00, 0x10, 0x01, 0x00, // HEADERS |
3662 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3749 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3663 0x40, 0x06, 0x43, 0x6f, | 3750 0x40, 0x06, 0x43, 0x6f, |
3664 0x6f, 0x6b, 0x69, 0x65, | 3751 0x6f, 0x6b, 0x69, 0x65, |
3665 0x07, 0x66, 0x6f, 0x6f, | 3752 0x07, 0x66, 0x6f, 0x6f, |
3666 0x3d, 0x62, 0x61, 0x72, | 3753 0x3d, 0x62, 0x61, 0x72, |
3667 | 3754 |
3668 0x00, 0x1c, 0x08, 0x00, // HEADERS | 3755 0x00, 0x14, 0x08, 0x00, // HEADERS |
3669 0x00, 0x00, 0x00, 0x01, // Stream 1 | 3756 0x00, 0x00, 0x00, 0x01, // Stream 1 |
3670 0x40, 0x06, 0x43, 0x6f, // (Note this is a valid continued encoding). | 3757 0x40, 0x06, 0x43, 0x6f, // (Note this is a valid continued encoding). |
3671 0x6f, 0x6b, 0x69, 0x65, | 3758 0x6f, 0x6b, 0x69, 0x65, |
3672 0x08, 0x62, 0x61, 0x7a, | 3759 0x08, 0x62, 0x61, 0x7a, |
3673 0x3d, 0x62, 0x69, 0x6e, | 3760 0x3d, 0x62, 0x69, 0x6e, |
3674 0x67, 0x40, 0x06, 0x43, | 3761 0x67, 0x40, 0x06, 0x43, |
3675 }; | 3762 }; |
3676 | 3763 |
3677 SpdyFramer framer(spdy_version_); | 3764 SpdyFramer framer(spdy_version_); |
3678 TestSpdyVisitor visitor(spdy_version_); | 3765 TestSpdyVisitor visitor(spdy_version_); |
(...skipping 13 matching lines...) Expand all Loading... |
3692 TEST_P(SpdyFramerTest, ReadGarbage) { | 3779 TEST_P(SpdyFramerTest, ReadGarbage) { |
3693 SpdyFramer framer(spdy_version_); | 3780 SpdyFramer framer(spdy_version_); |
3694 unsigned char garbage_frame[256]; | 3781 unsigned char garbage_frame[256]; |
3695 memset(garbage_frame, ~0, sizeof(garbage_frame)); | 3782 memset(garbage_frame, ~0, sizeof(garbage_frame)); |
3696 TestSpdyVisitor visitor(spdy_version_); | 3783 TestSpdyVisitor visitor(spdy_version_); |
3697 visitor.use_compression_ = false; | 3784 visitor.use_compression_ = false; |
3698 visitor.SimulateInFramer(garbage_frame, sizeof(garbage_frame)); | 3785 visitor.SimulateInFramer(garbage_frame, sizeof(garbage_frame)); |
3699 EXPECT_EQ(1, visitor.error_count_); | 3786 EXPECT_EQ(1, visitor.error_count_); |
3700 } | 3787 } |
3701 | 3788 |
| 3789 TEST_P(SpdyFramerTest, ReadGarbageWithValidLength) { |
| 3790 if (!IsSpdy4()) { |
| 3791 return; |
| 3792 } |
| 3793 SpdyFramer framer(spdy_version_); |
| 3794 const unsigned char kFrameData[] = { |
| 3795 0x00, 0x10, 0xff, 0xff, |
| 3796 0xff, 0xff, 0xff, 0xff, |
| 3797 0xff, 0xff, 0xff, 0xff, |
| 3798 0xff, 0xff, 0xff, 0xff, |
| 3799 }; |
| 3800 TestSpdyVisitor visitor(spdy_version_); |
| 3801 visitor.use_compression_ = false; |
| 3802 visitor.SimulateInFramer(kFrameData, arraysize(kFrameData)); |
| 3803 EXPECT_EQ(1, visitor.error_count_); |
| 3804 } |
| 3805 |
3702 TEST_P(SpdyFramerTest, ReadGarbageWithValidVersion) { | 3806 TEST_P(SpdyFramerTest, ReadGarbageWithValidVersion) { |
3703 if (IsSpdy4()) { | 3807 if (IsSpdy4()) { |
3704 // Not valid for SPDY 4 since there is no version field. | 3808 // Not valid for SPDY 4 since there is no version field. |
3705 return; | 3809 return; |
3706 } | 3810 } |
3707 SpdyFramer framer(spdy_version_); | 3811 SpdyFramer framer(spdy_version_); |
3708 const unsigned char kFrameData[] = { | 3812 const unsigned char kFrameData[] = { |
3709 0x80, spdy_version_ch_, 0xff, 0xff, | 3813 0x80, spdy_version_ch_, 0xff, 0xff, |
3710 0xff, 0xff, 0xff, 0xff, | 3814 0xff, 0xff, 0xff, 0xff, |
3711 }; | 3815 }; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3885 | 3989 |
3886 EXPECT_CALL(visitor, OnError(_)); | 3990 EXPECT_CALL(visitor, OnError(_)); |
3887 framer.ProcessInput("HTTP/1.0", 8); | 3991 framer.ProcessInput("HTTP/1.0", 8); |
3888 EXPECT_TRUE(framer.probable_http_response()); | 3992 EXPECT_TRUE(framer.probable_http_response()); |
3889 EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state()); | 3993 EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state()); |
3890 EXPECT_EQ(SpdyFramer::SPDY_INVALID_DATA_FRAME_FLAGS, framer.error_code()) | 3994 EXPECT_EQ(SpdyFramer::SPDY_INVALID_DATA_FRAME_FLAGS, framer.error_code()) |
3891 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3995 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3892 } | 3996 } |
3893 } | 3997 } |
3894 | 3998 |
3895 TEST_P(SpdyFramerTest, DataFrameFlags) { | 3999 TEST_P(SpdyFramerTest, DataFrameFlagsV2V3) { |
| 4000 if (spdy_version_ >= 4) { |
| 4001 return; |
| 4002 } |
| 4003 |
3896 for (int flags = 0; flags < 256; ++flags) { | 4004 for (int flags = 0; flags < 256; ++flags) { |
3897 SCOPED_TRACE(testing::Message() << "Flags " << flags); | 4005 SCOPED_TRACE(testing::Message() << "Flags " << flags); |
3898 | 4006 |
3899 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4007 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
3900 SpdyFramer framer(spdy_version_); | 4008 SpdyFramer framer(spdy_version_); |
3901 framer.set_visitor(&visitor); | 4009 framer.set_visitor(&visitor); |
3902 | 4010 |
3903 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); | 4011 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
3904 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 4012 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
3905 SetFrameFlags(frame.get(), flags, spdy_version_); | 4013 SetFrameFlags(frame.get(), flags, spdy_version_); |
(...skipping 15 matching lines...) Expand all Loading... |
3921 framer.error_code()) | 4029 framer.error_code()) |
3922 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4030 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3923 } else { | 4031 } else { |
3924 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4032 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
3925 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 4033 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
3926 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4034 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
3927 } | 4035 } |
3928 } | 4036 } |
3929 } | 4037 } |
3930 | 4038 |
| 4039 TEST_P(SpdyFramerTest, DataFrameFlagsV4) { |
| 4040 if (spdy_version_ < 4) { |
| 4041 return; |
| 4042 } |
| 4043 |
| 4044 uint8 valid_data_flags = DATA_FLAG_FIN | DATA_FLAG_END_SEGMENT | |
| 4045 DATA_FLAG_PAD_LOW | DATA_FLAG_PAD_HIGH; |
| 4046 |
| 4047 for (int flags = 0; flags < 256; ++flags) { |
| 4048 SCOPED_TRACE(testing::Message() << "Flags " << flags); |
| 4049 |
| 4050 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
| 4051 SpdyFramer framer(spdy_version_); |
| 4052 framer.set_visitor(&visitor); |
| 4053 |
| 4054 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
| 4055 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 4056 SetFrameFlags(frame.get(), flags, spdy_version_); |
| 4057 |
| 4058 if (flags & ~valid_data_flags) { |
| 4059 EXPECT_CALL(visitor, OnError(_)); |
| 4060 } else { |
| 4061 EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN)); |
| 4062 if ((flags & DATA_FLAG_PAD_LOW) || (flags & DATA_FLAG_PAD_HIGH)) { |
| 4063 // Expect Error since we don't set pad_high and pad_low in payload. |
| 4064 EXPECT_CALL(visitor, OnError(_)); |
| 4065 } else { |
| 4066 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 5, false)); |
| 4067 if (flags & DATA_FLAG_FIN) { |
| 4068 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true)); |
| 4069 } |
| 4070 } |
| 4071 } |
| 4072 |
| 4073 framer.ProcessInput(frame->data(), frame->size()); |
| 4074 if ((flags & ~valid_data_flags) || (flags & DATA_FLAG_PAD_LOW) || |
| 4075 (flags & DATA_FLAG_PAD_HIGH)) { |
| 4076 EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state()); |
| 4077 EXPECT_EQ(SpdyFramer::SPDY_INVALID_DATA_FRAME_FLAGS, |
| 4078 framer.error_code()) |
| 4079 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
| 4080 } else { |
| 4081 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
| 4082 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
| 4083 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
| 4084 } |
| 4085 } |
| 4086 } |
| 4087 |
3931 TEST_P(SpdyFramerTest, SynStreamFrameFlags) { | 4088 TEST_P(SpdyFramerTest, SynStreamFrameFlags) { |
3932 for (int flags = 0; flags < 256; ++flags) { | 4089 for (int flags = 0; flags < 256; ++flags) { |
3933 SCOPED_TRACE(testing::Message() << "Flags " << flags); | 4090 SCOPED_TRACE(testing::Message() << "Flags " << flags); |
3934 | 4091 |
3935 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4092 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
3936 testing::StrictMock<test::MockDebugVisitor> debug_visitor; | 4093 testing::StrictMock<test::MockDebugVisitor> debug_visitor; |
3937 SpdyFramer framer(spdy_version_); | 4094 SpdyFramer framer(spdy_version_); |
3938 framer.set_visitor(&visitor); | 4095 framer.set_visitor(&visitor); |
3939 framer.set_debug_visitor(&debug_visitor); | 4096 framer.set_debug_visitor(&debug_visitor); |
3940 | 4097 |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4430 SpdyFramer framer(spdy_version_); | 4587 SpdyFramer framer(spdy_version_); |
4431 framer.set_visitor(&visitor); | 4588 framer.set_visitor(&visitor); |
4432 framer.set_debug_visitor(&debug_visitor); | 4589 framer.set_debug_visitor(&debug_visitor); |
4433 | 4590 |
4434 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(1, SYN_STREAM, _, _)); | 4591 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(1, SYN_STREAM, _, _)); |
4435 | 4592 |
4436 SpdySynStreamIR syn_stream(1); | 4593 SpdySynStreamIR syn_stream(1); |
4437 syn_stream.set_priority(1); | 4594 syn_stream.set_priority(1); |
4438 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); | 4595 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); |
4439 // Adjust size to remove the name/value block. | 4596 // Adjust size to remove the name/value block. |
4440 if (IsSpdy4()) { | 4597 SetFrameLength( |
4441 SetFrameLength( | 4598 frame.get(), |
4442 frame.get(), | 4599 framer.GetSynStreamMinimumSize() - framer.GetControlFrameHeaderSize(), |
4443 framer.GetSynStreamMinimumSize(), | 4600 spdy_version_); |
4444 spdy_version_); | |
4445 } else { | |
4446 SetFrameLength( | |
4447 frame.get(), | |
4448 framer.GetSynStreamMinimumSize() - framer.GetControlFrameHeaderSize(), | |
4449 spdy_version_); | |
4450 } | |
4451 | 4601 |
4452 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(1, SYN_STREAM, _)); | 4602 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(1, SYN_STREAM, _)); |
4453 EXPECT_CALL(visitor, OnSynStream(1, 0, 1, false, false)); | 4603 EXPECT_CALL(visitor, OnSynStream(1, 0, 1, false, false)); |
4454 EXPECT_CALL(visitor, OnControlFrameHeaderData(1, NULL, 0)); | 4604 EXPECT_CALL(visitor, OnControlFrameHeaderData(1, NULL, 0)); |
4455 | 4605 |
4456 framer.ProcessInput(frame->data(), framer.GetSynStreamMinimumSize()); | 4606 framer.ProcessInput(frame->data(), framer.GetSynStreamMinimumSize()); |
4457 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4607 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4458 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 4608 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
4459 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4609 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
4460 } | 4610 } |
(...skipping 14 matching lines...) Expand all Loading... |
4475 TEST_P(SpdyFramerTest, RstStreamStatusBounds) { | 4625 TEST_P(SpdyFramerTest, RstStreamStatusBounds) { |
4476 DCHECK_GE(0xff, RST_STREAM_NUM_STATUS_CODES); | 4626 DCHECK_GE(0xff, RST_STREAM_NUM_STATUS_CODES); |
4477 | 4627 |
4478 const unsigned char kV3RstStreamInvalid[] = { | 4628 const unsigned char kV3RstStreamInvalid[] = { |
4479 0x80, spdy_version_ch_, 0x00, 0x03, | 4629 0x80, spdy_version_ch_, 0x00, 0x03, |
4480 0x00, 0x00, 0x00, 0x08, | 4630 0x00, 0x00, 0x00, 0x08, |
4481 0x00, 0x00, 0x00, 0x01, | 4631 0x00, 0x00, 0x00, 0x01, |
4482 0x00, 0x00, 0x00, RST_STREAM_INVALID | 4632 0x00, 0x00, 0x00, RST_STREAM_INVALID |
4483 }; | 4633 }; |
4484 const unsigned char kV4RstStreamInvalid[] = { | 4634 const unsigned char kV4RstStreamInvalid[] = { |
4485 0x00, 0x0c, 0x03, 0x00, | 4635 0x00, 0x04, 0x03, 0x00, |
4486 0x00, 0x00, 0x00, 0x01, | 4636 0x00, 0x00, 0x00, 0x01, |
4487 0x00, 0x00, 0x00, RST_STREAM_INVALID | 4637 0x00, 0x00, 0x00, RST_STREAM_INVALID |
4488 }; | 4638 }; |
4489 | 4639 |
4490 const unsigned char kV3RstStreamNumStatusCodes[] = { | 4640 const unsigned char kV3RstStreamNumStatusCodes[] = { |
4491 0x80, spdy_version_ch_, 0x00, 0x03, | 4641 0x80, spdy_version_ch_, 0x00, 0x03, |
4492 0x00, 0x00, 0x00, 0x08, | 4642 0x00, 0x00, 0x00, 0x08, |
4493 0x00, 0x00, 0x00, 0x01, | 4643 0x00, 0x00, 0x00, 0x01, |
4494 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES | 4644 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES |
4495 }; | 4645 }; |
4496 const unsigned char kV4RstStreamNumStatusCodes[] = { | 4646 const unsigned char kV4RstStreamNumStatusCodes[] = { |
4497 0x00, 0x0c, 0x03, 0x00, | 4647 0x00, 0x04, 0x03, 0x00, |
4498 0x00, 0x00, 0x00, 0x01, | 4648 0x00, 0x00, 0x00, 0x01, |
4499 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES | 4649 0x00, 0x00, 0x00, RST_STREAM_NUM_STATUS_CODES |
4500 }; | 4650 }; |
4501 | 4651 |
4502 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4652 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
4503 SpdyFramer framer(spdy_version_); | 4653 SpdyFramer framer(spdy_version_); |
4504 framer.set_visitor(&visitor); | 4654 framer.set_visitor(&visitor); |
4505 | 4655 |
4506 EXPECT_CALL(visitor, OnRstStream(1, RST_STREAM_INVALID)); | 4656 EXPECT_CALL(visitor, OnRstStream(1, RST_STREAM_INVALID)); |
4507 if (IsSpdy4()) { | 4657 if (IsSpdy4()) { |
(...skipping 29 matching lines...) Expand all Loading... |
4537 0x00, 0x00, 0x00, 0x04, | 4687 0x00, 0x00, 0x00, 0x04, |
4538 0xff, 0xff, 0xff, 0xff, | 4688 0xff, 0xff, 0xff, 0xff, |
4539 }; | 4689 }; |
4540 const unsigned char kV3FrameData[] = { | 4690 const unsigned char kV3FrameData[] = { |
4541 0x80, spdy_version_ch_, 0x00, 0x07, | 4691 0x80, spdy_version_ch_, 0x00, 0x07, |
4542 0x00, 0x00, 0x00, 0x08, | 4692 0x00, 0x00, 0x00, 0x08, |
4543 0xff, 0xff, 0xff, 0xff, | 4693 0xff, 0xff, 0xff, 0xff, |
4544 0x00, 0x00, 0x00, 0x00, | 4694 0x00, 0x00, 0x00, 0x00, |
4545 }; | 4695 }; |
4546 const unsigned char kV4FrameData[] = { | 4696 const unsigned char kV4FrameData[] = { |
4547 0x00, 0x10, 0x07, 0x00, | 4697 0x00, 0x08, 0x07, 0x00, |
4548 0x00, 0x00, 0x00, 0x00, | 4698 0x00, 0x00, 0x00, 0x00, |
4549 0xff, 0xff, 0xff, 0xff, | 4699 0xff, 0xff, 0xff, 0xff, |
4550 0x00, 0x00, 0x00, 0x00, | 4700 0x00, 0x00, 0x00, 0x00, |
4551 }; | 4701 }; |
4552 | 4702 |
4553 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4703 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
4554 SpdyFramer framer(spdy_version_); | 4704 SpdyFramer framer(spdy_version_); |
4555 framer.set_visitor(&visitor); | 4705 framer.set_visitor(&visitor); |
4556 | 4706 |
4557 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); | 4707 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); |
(...skipping 28 matching lines...) Expand all Loading... |
4586 SpdyBlockedIR blocked_ir(0); | 4736 SpdyBlockedIR blocked_ir(0); |
4587 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 4737 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
4588 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); | 4738 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); |
4589 | 4739 |
4590 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4740 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4591 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 4741 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
4592 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4742 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
4593 } | 4743 } |
4594 | 4744 |
4595 } // namespace net | 4745 } // namespace net |
OLD | NEW |