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

Side by Side Diff: net/spdy/spdy_framer_test.cc

Issue 138803002: SPDY4: Turn SYN_STREAM and SYN_REPLY into HEADERS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows bool-cast fix. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 } 961 }
962 } 962 }
963 963
964 TEST_P(SpdyFramerTest, DuplicateHeader) { 964 TEST_P(SpdyFramerTest, DuplicateHeader) {
965 SpdyFramer framer(spdy_version_); 965 SpdyFramer framer(spdy_version_);
966 // Frame builder with plentiful buffer size. 966 // Frame builder with plentiful buffer size.
967 SpdyFrameBuilder frame(1024); 967 SpdyFrameBuilder frame(1024);
968 if (spdy_version_ < 4) { 968 if (spdy_version_ < 4) {
969 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); 969 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE);
970 frame.WriteUInt32(3); // stream_id 970 frame.WriteUInt32(3); // stream_id
971 frame.WriteUInt32(0); // associated stream id
972 frame.WriteUInt16(0); // Priority.
971 } else { 973 } else {
972 frame.WriteFramePrefix(framer, SYN_STREAM, CONTROL_FLAG_NONE, 3); 974 frame.WriteFramePrefix(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3);
975 frame.WriteUInt32(framer.GetHighestPriority());
973 } 976 }
974 977
975 frame.WriteUInt32(0); // associated stream id
976 frame.WriteUInt16(0); // Priority.
977
978 if (IsSpdy2()) { 978 if (IsSpdy2()) {
979 frame.WriteUInt16(2); // Number of headers. 979 frame.WriteUInt16(2); // Number of headers.
980 frame.WriteString("name"); 980 frame.WriteString("name");
981 frame.WriteString("value1"); 981 frame.WriteString("value1");
982 frame.WriteString("name"); 982 frame.WriteString("name");
983 frame.WriteString("value2"); 983 frame.WriteString("value2");
984 } else { 984 } else {
985 frame.WriteUInt32(2); // Number of headers. 985 frame.WriteUInt32(2); // Number of headers.
986 frame.WriteStringPiece32("name"); 986 frame.WriteStringPiece32("name");
987 frame.WriteStringPiece32("value1"); 987 frame.WriteStringPiece32("value1");
(...skipping 14 matching lines...) Expand all
1002 &new_headers)); 1002 &new_headers));
1003 } 1003 }
1004 1004
1005 TEST_P(SpdyFramerTest, MultiValueHeader) { 1005 TEST_P(SpdyFramerTest, MultiValueHeader) {
1006 SpdyFramer framer(spdy_version_); 1006 SpdyFramer framer(spdy_version_);
1007 // Frame builder with plentiful buffer size. 1007 // Frame builder with plentiful buffer size.
1008 SpdyFrameBuilder frame(1024); 1008 SpdyFrameBuilder frame(1024);
1009 if (spdy_version_ < 4) { 1009 if (spdy_version_ < 4) {
1010 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); 1010 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE);
1011 frame.WriteUInt32(3); // stream_id 1011 frame.WriteUInt32(3); // stream_id
1012 frame.WriteUInt32(0); // associated stream id
1013 frame.WriteUInt16(0); // Priority.
1012 } else { 1014 } else {
1013 frame.WriteFramePrefix(framer, SYN_STREAM, CONTROL_FLAG_NONE, 3); 1015 frame.WriteFramePrefix(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3);
1016 frame.WriteUInt32(framer.GetHighestPriority());
1014 } 1017 }
1015 1018
1016 frame.WriteUInt32(0); // associated stream id
1017 frame.WriteUInt16(0); // Priority.
1018
1019 string value("value1\0value2"); 1019 string value("value1\0value2");
1020 if (IsSpdy2()) { 1020 if (IsSpdy2()) {
1021 frame.WriteUInt16(1); // Number of headers. 1021 frame.WriteUInt16(1); // Number of headers.
1022 frame.WriteString("name"); 1022 frame.WriteString("name");
1023 frame.WriteString(value); 1023 frame.WriteString(value);
1024 } else { 1024 } else {
1025 frame.WriteUInt32(1); // Number of headers. 1025 frame.WriteUInt32(1); // Number of headers.
1026 frame.WriteStringPiece32("name"); 1026 frame.WriteStringPiece32("name");
1027 frame.WriteStringPiece32(value); 1027 frame.WriteStringPiece32(value);
1028 } 1028 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3 1270 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3
1271 0x00, 0x00, 0x00, 0x00, 1271 0x00, 0x00, 0x00, 0x00,
1272 1272
1273 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 1273 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3
1274 0x00, 0x00, 0x00, 0x08, 1274 0x00, 0x00, 0x00, 0x08,
1275 0x00, 0x00, 0x00, 0x03, 1275 0x00, 0x00, 0x00, 0x03,
1276 0x00, 0x00, 0x00, 0x00, 1276 0x00, 0x00, 0x00, 0x00,
1277 }; 1277 };
1278 1278
1279 const unsigned char kV4Input[] = { 1279 const unsigned char kV4Input[] = {
1280 0x00, 0x1e, 0x01, 0x00, // SYN_STREAM #1 1280 0x00, 0x1c, 0x08, 0x08, // SYN_STREAM #1
1281 0x00, 0x00, 0x00, 0x01, 1281 0x00, 0x00, 0x00, 0x01,
1282 0x00, 0x00, 0x00, 0x00, 1282 0x00, 0x00, 0x00, 0x00,
1283 0x00, 0x00, 0x00, 0x00, 1283 0x00, 0x00, 0x00, 0x01,
1284 0x00, 0x01, 0x00, 0x00,
1285 0x00, 0x02, 'h', 'h',
1286 0x00, 0x00, 0x00, 0x02, 1284 0x00, 0x00, 0x00, 0x02,
1287 'v', 'v', 1285 'h', 'h', 0x00, 0x00,
1286 0x00, 0x02, 'v', 'v',
1288 1287
1289 0x00, 0x24, 0x08, 0x00, // HEADERS on Stream #1 1288 0x00, 0x24, 0x08, 0x00, // HEADERS on Stream #1
1290 0x00, 0x00, 0x00, 0x01, 1289 0x00, 0x00, 0x00, 0x01,
1291 0x00, 0x00, 0x00, 0x02, 1290 0x00, 0x00, 0x00, 0x02,
1292 0x00, 0x00, 0x00, 0x02, 1291 0x00, 0x00, 0x00, 0x02,
1293 'h', '2', 0x00, 0x00, 1292 'h', '2', 0x00, 0x00,
1294 0x00, 0x02, 'v', '2', 1293 0x00, 0x02, 'v', '2',
1295 0x00, 0x00, 0x00, 0x02, 1294 0x00, 0x00, 0x00, 0x02,
1296 'h', '3', 0x00, 0x00, 1295 'h', '3', 0x00, 0x00,
1297 0x00, 0x02, 'v', '3', 1296 0x00, 0x02, 'v', '3',
1298 1297
1299 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1 1298 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1
1300 0x00, 0x00, 0x00, 0x01, 1299 0x00, 0x00, 0x00, 0x01,
1301 0xde, 0xad, 0xbe, 0xef, 1300 0xde, 0xad, 0xbe, 0xef,
1302 0xde, 0xad, 0xbe, 0xef, 1301 0xde, 0xad, 0xbe, 0xef,
1303 0xde, 0xad, 0xbe, 0xef, 1302 0xde, 0xad, 0xbe, 0xef,
1304 1303
1305 0x00, 0x12, 0x01, 0x00, // SYN Stream #3 1304 0x00, 0x10, 0x08, 0x08, // SYN Stream #3
1306 0x00, 0x00, 0x00, 0x03, 1305 0x00, 0x00, 0x00, 0x03,
1307 0x00, 0x00, 0x00, 0x00, 1306 0x00, 0x00, 0x00, 0x00,
1308 0x00, 0x00, 0x00, 0x00, 1307 0x00, 0x00, 0x00, 0x00,
1309 0x00, 0x00,
1310 1308
1311 0x00, 0x10, 0x00, 0x00, // DATA on Stream #3 1309 0x00, 0x10, 0x00, 0x00, // DATA on Stream #3
1312 0x00, 0x00, 0x00, 0x03, 1310 0x00, 0x00, 0x00, 0x03,
1313 0xde, 0xad, 0xbe, 0xef, 1311 0xde, 0xad, 0xbe, 0xef,
1314 0xde, 0xad, 0xbe, 0xef, 1312 0xde, 0xad, 0xbe, 0xef,
1315 1313
1316 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 1314 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1
1317 0x00, 0x00, 0x00, 0x01, 1315 0x00, 0x00, 0x00, 0x01,
1318 0xde, 0xad, 0xbe, 0xef, 1316 0xde, 0xad, 0xbe, 0xef,
1319 1317
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 0x00, 0x00, 0x00, 0x0c, 1398 0x00, 0x00, 0x00, 0x0c,
1401 0xde, 0xad, 0xbe, 0xef, 1399 0xde, 0xad, 0xbe, 0xef,
1402 0xde, 0xad, 0xbe, 0xef, 1400 0xde, 0xad, 0xbe, 0xef,
1403 0xde, 0xad, 0xbe, 0xef, 1401 0xde, 0xad, 0xbe, 0xef,
1404 1402
1405 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF 1403 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF
1406 0x01, 0x00, 0x00, 0x04, 1404 0x01, 0x00, 0x00, 0x04,
1407 0xde, 0xad, 0xbe, 0xef, 1405 0xde, 0xad, 0xbe, 0xef,
1408 }; 1406 };
1409 const unsigned char kV4Input[] = { 1407 const unsigned char kV4Input[] = {
1410 0x00, 0x1e, 0x01, 0x00, // SYN_STREAM #1 1408 0x00, 0x1c, 0x08, 0x08, // SYN_STREAM #1
1411 0x00, 0x00, 0x00, 0x01, 1409 0x00, 0x00, 0x00, 0x01,
1412 0x00, 0x00, 0x00, 0x00, 1410 0x00, 0x00, 0x00, 0x00,
1413 0x00, 0x00, 0x00, 0x00, 1411 0x00, 0x00, 0x00, 0x01,
1414 0x00, 0x01, 0x00, 0x00,
1415 0x00, 0x02, 'h', 'h',
1416 0x00, 0x00, 0x00, 0x02, 1412 0x00, 0x00, 0x00, 0x02,
1417 'v', 'v', 1413 'h', 'h', 0x00, 0x00,
1414 0x00, 0x02, 'v', 'v',
1418 1415
1419 0x00, 0x18, 0x02, 0x00, // SYN REPLY Stream #1 1416 0x00, 0x18, 0x08, 0x00, // SYN REPLY Stream #1
1420 0x00, 0x00, 0x00, 0x01, 1417 0x00, 0x00, 0x00, 0x01,
1421 0x00, 0x00, 0x00, 0x01, 1418 0x00, 0x00, 0x00, 0x01,
1422 0x00, 0x00, 0x00, 0x02, 1419 0x00, 0x00, 0x00, 0x02,
1423 'a', 'a', 0x00, 0x00, 1420 'a', 'a', 0x00, 0x00,
1424 0x00, 0x02, 'b', 'b', 1421 0x00, 0x02, 'b', 'b',
1425 1422
1426 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1 1423 0x00, 0x14, 0x00, 0x00, // DATA on Stream #1
1427 0x00, 0x00, 0x00, 0x01, 1424 0x00, 0x00, 0x00, 0x01,
1428 0xde, 0xad, 0xbe, 0xef, 1425 0xde, 0xad, 0xbe, 0xef,
1429 0xde, 0xad, 0xbe, 0xef, 1426 0xde, 0xad, 0xbe, 0xef,
1430 0xde, 0xad, 0xbe, 0xef, 1427 0xde, 0xad, 0xbe, 0xef,
1431 1428
1432 0x00, 0x0c, 0x00, 0x01, // DATA on Stream #1, with FIN 1429 0x00, 0x0c, 0x00, 0x01, // DATA on Stream #1, with FIN
1433 0x00, 0x00, 0x00, 0x01, 1430 0x00, 0x00, 0x00, 0x01,
1434 0xde, 0xad, 0xbe, 0xef, 1431 0xde, 0xad, 0xbe, 0xef,
1435 }; 1432 };
1436 1433
1437 TestSpdyVisitor visitor(spdy_version_); 1434 TestSpdyVisitor visitor(spdy_version_);
1438 if (IsSpdy2()) { 1435 if (IsSpdy2()) {
1439 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); 1436 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input));
1440 } else if (IsSpdy3()) { 1437 } else if (IsSpdy3()) {
1441 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); 1438 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input));
1442 } else { 1439 } else {
1443 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input)); 1440 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input));
1444 } 1441 }
1445 1442
1446 EXPECT_EQ(0, visitor.error_count_); 1443 EXPECT_EQ(0, visitor.error_count_);
1447 EXPECT_EQ(1, visitor.syn_frame_count_); 1444 EXPECT_EQ(1, visitor.syn_frame_count_);
1448 EXPECT_EQ(1, visitor.syn_reply_frame_count_); 1445 if (IsSpdy4()) {
1449 EXPECT_EQ(0, visitor.headers_frame_count_); 1446 EXPECT_EQ(0, visitor.syn_reply_frame_count_);
1447 EXPECT_EQ(1, visitor.headers_frame_count_);
1448 } else {
1449 EXPECT_EQ(1, visitor.syn_reply_frame_count_);
1450 EXPECT_EQ(0, visitor.headers_frame_count_);
1451 }
1450 EXPECT_EQ(16, visitor.data_bytes_); 1452 EXPECT_EQ(16, visitor.data_bytes_);
1451 EXPECT_EQ(0, visitor.fin_frame_count_); 1453 EXPECT_EQ(0, visitor.fin_frame_count_);
1452 EXPECT_EQ(0, visitor.fin_flag_count_); 1454 EXPECT_EQ(0, visitor.fin_flag_count_);
1453 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); 1455 EXPECT_EQ(1, visitor.zero_length_data_frame_count_);
1454 EXPECT_EQ(2, visitor.data_frame_count_); 1456 EXPECT_EQ(2, visitor.data_frame_count_);
1455 } 1457 }
1456 1458
1457 // Test that the FIN flag on a SYN reply frame signifies EOF. 1459 // Test that the FIN flag on a SYN reply frame signifies EOF.
1458 TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { 1460 TEST_P(SpdyFramerTest, FinOnSynReplyFrame) {
1459 const unsigned char kV2Input[] = { 1461 const unsigned char kV2Input[] = {
(...skipping 25 matching lines...) Expand all
1485 1487
1486 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1 1488 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1
1487 0x01, 0x00, 0x00, 0x14, 1489 0x01, 0x00, 0x00, 0x14,
1488 0x00, 0x00, 0x00, 0x01, 1490 0x00, 0x00, 0x00, 0x01,
1489 0x00, 0x00, 0x00, 0x01, 1491 0x00, 0x00, 0x00, 0x01,
1490 0x00, 0x00, 0x00, 0x02, 1492 0x00, 0x00, 0x00, 0x02,
1491 'a', 'a', 0x00, 0x00, 1493 'a', 'a', 0x00, 0x00,
1492 0x00, 0x02, 'b', 'b', 1494 0x00, 0x02, 'b', 'b',
1493 }; 1495 };
1494 const unsigned char kV4Input[] = { 1496 const unsigned char kV4Input[] = {
1495 0x00, 0x1e, 0x01, 0x00, // SYN_STREAM #1 1497 0x00, 0x1c, 0x08, 0x08, // SYN_STREAM #1
1496 0x00, 0x00, 0x00, 0x01, 1498 0x00, 0x00, 0x00, 0x01,
1497 0x00, 0x00, 0x00, 0x00, 1499 0x00, 0x00, 0x00, 0x00,
1498 0x00, 0x00, 0x00, 0x00, 1500 0x00, 0x00, 0x00, 0x01,
1499 0x00, 0x01, 0x00, 0x00,
1500 0x00, 0x02, 'h', 'h',
1501 0x00, 0x00, 0x00, 0x02, 1501 0x00, 0x00, 0x00, 0x02,
1502 'v', 'v', 1502 'h', 'h', 0x00, 0x00,
1503 0x00, 0x02, 'v', 'v',
1503 1504
1504 0x00, 0x18, 0x02, 0x01, // SYN_REPLY #1, with FIN 1505 0x00, 0x18, 0x08, 0x01, // SYN_REPLY #1, with FIN
1505 0x00, 0x00, 0x00, 0x01, 1506 0x00, 0x00, 0x00, 0x01,
1506 0x00, 0x00, 0x00, 0x01, 1507 0x00, 0x00, 0x00, 0x01,
1507 0x00, 0x00, 0x00, 0x02, 1508 0x00, 0x00, 0x00, 0x02,
1508 'a', 'a', 0x00, 0x00, 1509 'a', 'a', 0x00, 0x00,
1509 0x00, 0x02, 'b', 'b', 1510 0x00, 0x02, 'b', 'b',
1510 }; 1511 };
1511 1512
1512 TestSpdyVisitor visitor(spdy_version_); 1513 TestSpdyVisitor visitor(spdy_version_);
1513 if (IsSpdy2()) { 1514 if (IsSpdy2()) {
1514 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); 1515 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input));
1515 } else if (IsSpdy3()) { 1516 } else if (IsSpdy3()) {
1516 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); 1517 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input));
1517 } else { 1518 } else {
1518 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input)); 1519 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input));
1519 } 1520 }
1520 1521
1521 EXPECT_EQ(0, visitor.error_count_); 1522 EXPECT_EQ(0, visitor.error_count_);
1522 EXPECT_EQ(1, visitor.syn_frame_count_); 1523 EXPECT_EQ(1, visitor.syn_frame_count_);
1523 EXPECT_EQ(1, visitor.syn_reply_frame_count_); 1524 if (IsSpdy4()) {
1524 EXPECT_EQ(0, visitor.headers_frame_count_); 1525 EXPECT_EQ(0, visitor.syn_reply_frame_count_);
1526 EXPECT_EQ(1, visitor.headers_frame_count_);
1527 } else {
1528 EXPECT_EQ(1, visitor.syn_reply_frame_count_);
1529 EXPECT_EQ(0, visitor.headers_frame_count_);
1530 }
1525 EXPECT_EQ(0, visitor.data_bytes_); 1531 EXPECT_EQ(0, visitor.data_bytes_);
1526 EXPECT_EQ(0, visitor.fin_frame_count_); 1532 EXPECT_EQ(0, visitor.fin_frame_count_);
1527 EXPECT_EQ(1, visitor.fin_flag_count_); 1533 EXPECT_EQ(1, visitor.fin_flag_count_);
1528 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); 1534 EXPECT_EQ(1, visitor.zero_length_data_frame_count_);
1529 EXPECT_EQ(0, visitor.data_frame_count_); 1535 EXPECT_EQ(0, visitor.data_frame_count_);
1530 } 1536 }
1531 1537
1532 TEST_P(SpdyFramerTest, HeaderCompression) { 1538 TEST_P(SpdyFramerTest, HeaderCompression) {
1533 SpdyFramer send_framer(spdy_version_); 1539 SpdyFramer send_framer(spdy_version_);
1534 SpdyFramer recv_framer(spdy_version_); 1540 SpdyFramer recv_framer(spdy_version_);
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 0x00, 0x02, 0x00, 0x00, 1928 0x00, 0x02, 0x00, 0x00,
1923 0x00, 0x03, 'b', 'a', 1929 0x00, 0x03, 'b', 'a',
1924 'r', 0x00, 0x00, 0x00, 1930 'r', 0x00, 0x00, 0x00,
1925 0x03, 'f', 'o', 'o', 1931 0x03, 'f', 'o', 'o',
1926 0x00, 0x00, 0x00, 0x03, 1932 0x00, 0x00, 0x00, 0x03,
1927 'f', 'o', 'o', 0x00, 1933 'f', 'o', 'o', 0x00,
1928 0x00, 0x00, 0x03, 'b', 1934 0x00, 0x00, 0x03, 'b',
1929 'a', 'r' 1935 'a', 'r'
1930 }; 1936 };
1931 const unsigned char kV4FrameData[] = { 1937 const unsigned char kV4FrameData[] = {
1932 0x00, 0x2e, 0x01, 0x00, 1938 0x00, 0x2c, 0x08, 0x08,
1933 0x00, 0x00, 0x00, 0x01, 1939 0x00, 0x00, 0x00, 0x01,
1934 0x00, 0x00, 0x00, 0x00, 1940 0x00, 0x00, 0x00, 0x07,
1935 kPri, kCre, 0x00, 0x00, 1941 0x00, 0x00, 0x00, 0x02,
1936 0x00, 0x02, 0x00, 0x00,
1937 0x00, 0x03, 'b', 'a',
1938 'r', 0x00, 0x00, 0x00,
1939 0x03, 'f', 'o', 'o',
1940 0x00, 0x00, 0x00, 0x03, 1942 0x00, 0x00, 0x00, 0x03,
1941 'f', 'o', 'o', 0x00, 1943 'b', 'a', 'r', 0x00,
1942 0x00, 0x00, 0x03, 'b', 1944 0x00, 0x00, 0x03, 'f',
1943 'a', 'r' 1945 'o', 'o', 0x00, 0x00,
1946 0x00, 0x03, 'f', 'o',
1947 'o', 0x00, 0x00, 0x00,
1948 0x03, 'b', 'a', 'r'
1944 }; 1949 };
1945 scoped_ptr<SpdyFrame> frame( 1950 scoped_ptr<SpdyFrame> frame(
1946 framer.CreateSynStream(1, // stream id 1951 framer.CreateSynStream(1, // stream id
1947 0, // associated stream id 1952 0, // associated stream id
1948 framer.GetLowestPriority(), 1953 framer.GetLowestPriority(),
1949 kCre, // credential slot 1954 kCre, // credential slot
1950 CONTROL_FLAG_NONE, 1955 CONTROL_FLAG_NONE,
1951 &headers)); 1956 &headers));
1952 if (IsSpdy2()) { 1957 if (IsSpdy2()) {
1953 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 1958 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 0x00, 0x00, 0x00, 0x00, 1992 0x00, 0x00, 0x00, 0x00,
1988 0x00, 0x02, 0x00, 0x00, 1993 0x00, 0x02, 0x00, 0x00,
1989 0x00, 0x00, 0x00, 0x00, 1994 0x00, 0x00, 0x00, 0x00,
1990 0x00, 0x03, 'f', 'o', 1995 0x00, 0x03, 'f', 'o',
1991 'o', 0x00, 0x00, 0x00, 1996 'o', 0x00, 0x00, 0x00,
1992 0x03, 'f', 'o', 'o', 1997 0x03, 'f', 'o', 'o',
1993 0x00, 0x00, 0x00, 0x03, 1998 0x00, 0x00, 0x00, 0x03,
1994 'b', 'a', 'r' 1999 'b', 'a', 'r'
1995 }; 2000 };
1996 const unsigned char kV4FrameData[] = { 2001 const unsigned char kV4FrameData[] = {
1997 0x00, 0x2b, 0x01, 0x01, 2002 0x00, 0x29, 0x08, 0x09,
1998 0x7f, 0xff, 0xff, 0xff,
1999 0x7f, 0xff, 0xff, 0xff, 2003 0x7f, 0xff, 0xff, 0xff,
2000 0x00, 0x00, 0x00, 0x00, 2004 0x00, 0x00, 0x00, 0x00,
2001 0x00, 0x02, 0x00, 0x00, 2005 0x00, 0x00, 0x00, 0x02,
2002 0x00, 0x00, 0x00, 0x00, 2006 0x00, 0x00, 0x00, 0x00,
2003 0x00, 0x03, 'f', 'o',
2004 'o', 0x00, 0x00, 0x00,
2005 0x03, 'f', 'o', 'o',
2006 0x00, 0x00, 0x00, 0x03, 2007 0x00, 0x00, 0x00, 0x03,
2007 'b', 'a', 'r' 2008 'f', 'o', 'o', 0x00,
2009 0x00, 0x00, 0x03, 'f',
2010 'o', 'o', 0x00, 0x00,
2011 0x00, 0x03, 'b', 'a',
2012 'r'
2008 }; 2013 };
2009 scoped_ptr<SpdyFrame> frame( 2014 scoped_ptr<SpdyFrame> frame(
2010 framer.CreateSynStream(0x7fffffff, // stream id 2015 framer.CreateSynStream(0x7fffffff, // stream id
2011 0x7fffffff, // associated stream id 2016 0x7fffffff, // associated stream id
2012 framer.GetHighestPriority(), 2017 framer.GetHighestPriority(),
2013 0, // credential slot 2018 0, // credential slot
2014 CONTROL_FLAG_FIN, 2019 CONTROL_FLAG_FIN,
2015 &headers)); 2020 &headers));
2016 if (IsSpdy2()) { 2021 if (IsSpdy2()) {
2017 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2022 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 kPri, 0x00, 0x00, 0x00, 2057 kPri, 0x00, 0x00, 0x00,
2053 0x00, 0x02, 0x00, 0x00, 2058 0x00, 0x02, 0x00, 0x00,
2054 0x00, 0x03, 'b', 'a', 2059 0x00, 0x03, 'b', 'a',
2055 'r', 0x00, 0x00, 0x00, 2060 'r', 0x00, 0x00, 0x00,
2056 0x03, 'f', 'o', 'o', 2061 0x03, 'f', 'o', 'o',
2057 0x00, 0x00, 0x00, 0x03, 2062 0x00, 0x00, 0x00, 0x03,
2058 'f', 'o', 'o', 0x00, 2063 'f', 'o', 'o', 0x00,
2059 0x00, 0x00, 0x00 2064 0x00, 0x00, 0x00
2060 }; 2065 };
2061 const unsigned char kV4FrameData[] = { 2066 const unsigned char kV4FrameData[] = {
2062 0x00, 0x2b, 0x01, 0x01, 2067 0x00, 0x29, 0x08, 0x09,
2063 0x7f, 0xff, 0xff, 0xff, 2068 0x7f, 0xff, 0xff, 0xff,
2064 0x7f, 0xff, 0xff, 0xff, 2069 0x00, 0x00, 0x00, 0x01,
2065 kPri, 0x00, 0x00, 0x00, 2070 0x00, 0x00, 0x00, 0x02,
2066 0x00, 0x02, 0x00, 0x00,
2067 0x00, 0x03, 'b', 'a',
2068 'r', 0x00, 0x00, 0x00,
2069 0x03, 'f', 'o', 'o',
2070 0x00, 0x00, 0x00, 0x03, 2071 0x00, 0x00, 0x00, 0x03,
2071 'f', 'o', 'o', 0x00, 2072 'b', 'a', 'r', 0x00,
2072 0x00, 0x00, 0x00 2073 0x00, 0x00, 0x03, 'f',
2074 'o', 'o', 0x00, 0x00,
2075 0x00, 0x03, 'f', 'o',
2076 'o', 0x00, 0x00, 0x00,
2077 0x00
2073 }; 2078 };
2074 scoped_ptr<SpdyFrame> frame( 2079 scoped_ptr<SpdyFrame> frame(
2075 framer.CreateSynStream(0x7fffffff, // stream id 2080 framer.CreateSynStream(0x7fffffff, // stream id
2076 0x7fffffff, // associated stream id 2081 0x7fffffff, // associated stream id
2077 1, // priority 2082 1, // priority
2078 0, // credential slot 2083 0, // credential slot
2079 CONTROL_FLAG_FIN, 2084 CONTROL_FLAG_FIN,
2080 &headers)); 2085 &headers));
2081 if (IsSpdy2()) { 2086 if (IsSpdy2()) {
2082 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2087 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 0xE5, 0x0B, 0x66, 0x80, 2139 0xE5, 0x0B, 0x66, 0x80,
2135 0x00, 0x4A, 0xCB, 0xCF, 2140 0x00, 0x4A, 0xCB, 0xCF,
2136 0x07, 0x08, 0x20, 0x10, 2141 0x07, 0x08, 0x20, 0x10,
2137 0x95, 0x96, 0x9F, 0x0F, 2142 0x95, 0x96, 0x9F, 0x0F,
2138 0xA2, 0x00, 0x02, 0x28, 2143 0xA2, 0x00, 0x02, 0x28,
2139 0x29, 0xB1, 0x08, 0x20, 2144 0x29, 0xB1, 0x08, 0x20,
2140 0x80, 0x00, 0x00, 0x00, 2145 0x80, 0x00, 0x00, 0x00,
2141 0x00, 0xFF, 0xFF, 2146 0x00, 0xFF, 0xFF,
2142 }; 2147 };
2143 const unsigned char kV4FrameData[] = { 2148 const unsigned char kV4FrameData[] = {
2144 0x00, 0x3b, 0x01, 0x00, 2149 0x00, 0x39, 0x08, 0x08,
2145 0x00, 0x00, 0x00, 0x01, 2150 0x00, 0x00, 0x00, 0x01,
2146 0x00, 0x00, 0x00, 0x00, 2151 0x00, 0x00, 0x00, 0x04,
2147 0x80, 0x00, 0x38, 0xea, 2152 0x38, 0xea, 0xe3, 0xc6,
2148 0xe3, 0xc6, 0xa7, 0xc2, 2153 0xa7, 0xc2, 0x02, 0xe5,
2149 0x02, 0xe5, 0x0e, 0x50, 2154 0x0e, 0x50, 0xc2, 0x4b,
2150 0xc2, 0x4b, 0x4a, 0x04, 2155 0x4a, 0x04, 0xe5, 0x0b,
2151 0xe5, 0x0b, 0x66, 0x80, 2156 0x66, 0x80, 0x00, 0x4a,
2152 0x00, 0x4a, 0xcb, 0xcf, 2157 0xcb, 0xcf, 0x07, 0x08,
2153 0x07, 0x08, 0x20, 0x10, 2158 0x20, 0x10, 0x95, 0x96,
2154 0x95, 0x96, 0x9f, 0x0f, 2159 0x9f, 0x0f, 0xa2, 0x00,
2155 0xa2, 0x00, 0x02, 0x28, 2160 0x02, 0x28, 0x29, 0xb1,
2156 0x29, 0xb1, 0x08, 0x20, 2161 0x08, 0x20, 0x80, 0x00,
2157 0x80, 0x00, 0x00, 0x00, 2162 0x00, 0x00, 0x00, 0xff,
2158 0x00, 0xff, 0xff, 2163 0xff,
2159 }; 2164 };
2160 scoped_ptr<SpdyFrame> frame( 2165 scoped_ptr<SpdyFrame> frame(
2161 framer.CreateSynStream(1, // stream id 2166 framer.CreateSynStream(1, // stream id
2162 0, // associated stream id 2167 0, // associated stream id
2163 priority, 2168 priority,
2164 0, // credential slot 2169 0, // credential slot
2165 CONTROL_FLAG_NONE, 2170 CONTROL_FLAG_NONE,
2166 &headers)); 2171 &headers));
2167 if (IsSpdy2()) { 2172 if (IsSpdy2()) {
2168 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2173 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 0x00, 0x00, 0x00, 0x02, 2209 0x00, 0x00, 0x00, 0x02,
2205 0x00, 0x00, 0x00, 0x03, 2210 0x00, 0x00, 0x00, 0x03,
2206 'b', 'a', 'r', 0x00, 2211 'b', 'a', 'r', 0x00,
2207 0x00, 0x00, 0x03, 'f', 2212 0x00, 0x00, 0x03, 'f',
2208 'o', 'o', 0x00, 0x00, 2213 'o', 'o', 0x00, 0x00,
2209 0x00, 0x03, 'f', 'o', 2214 0x00, 0x03, 'f', 'o',
2210 'o', 0x00, 0x00, 0x00, 2215 'o', 0x00, 0x00, 0x00,
2211 0x03, 'b', 'a', 'r' 2216 0x03, 'b', 'a', 'r'
2212 }; 2217 };
2213 const unsigned char kV4FrameData[] = { 2218 const unsigned char kV4FrameData[] = {
2214 0x00, 0x28, 0x02, 0x00, 2219 0x00, 0x28, 0x08, 0x00,
2215 0x00, 0x00, 0x00, 0x01, 2220 0x00, 0x00, 0x00, 0x01,
2216 0x00, 0x00, 0x00, 0x02, 2221 0x00, 0x00, 0x00, 0x02,
2217 0x00, 0x00, 0x00, 0x03, 2222 0x00, 0x00, 0x00, 0x03,
2218 'b', 'a', 'r', 0x00, 2223 'b', 'a', 'r', 0x00,
2219 0x00, 0x00, 0x03, 'f', 2224 0x00, 0x00, 0x03, 'f',
2220 'o', 'o', 0x00, 0x00, 2225 'o', 'o', 0x00, 0x00,
2221 0x00, 0x03, 'f', 'o', 2226 0x00, 0x03, 'f', 'o',
2222 'o', 0x00, 0x00, 0x00, 2227 'o', 0x00, 0x00, 0x00,
2223 0x03, 'b', 'a', 'r' 2228 0x03, 'b', 'a', 'r'
2224 }; 2229 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2259 0x00, 0x00, 0x00, 0x02, 2264 0x00, 0x00, 0x00, 0x02,
2260 0x00, 0x00, 0x00, 0x00, 2265 0x00, 0x00, 0x00, 0x00,
2261 0x00, 0x00, 0x00, 0x03, 2266 0x00, 0x00, 0x00, 0x03,
2262 'f', 'o', 'o', 0x00, 2267 'f', 'o', 'o', 0x00,
2263 0x00, 0x00, 0x03, 'f', 2268 0x00, 0x00, 0x03, 'f',
2264 'o', 'o', 0x00, 0x00, 2269 'o', 'o', 0x00, 0x00,
2265 0x00, 0x03, 'b', 'a', 2270 0x00, 0x03, 'b', 'a',
2266 'r' 2271 'r'
2267 }; 2272 };
2268 const unsigned char kV4FrameData[] = { 2273 const unsigned char kV4FrameData[] = {
2269 0x00, 0x25, 0x02, 0x01, 2274 0x00, 0x25, 0x08, 0x01,
2270 0x7f, 0xff, 0xff, 0xff, 2275 0x7f, 0xff, 0xff, 0xff,
2271 0x00, 0x00, 0x00, 0x02, 2276 0x00, 0x00, 0x00, 0x02,
2272 0x00, 0x00, 0x00, 0x00, 2277 0x00, 0x00, 0x00, 0x00,
2273 0x00, 0x00, 0x00, 0x03, 2278 0x00, 0x00, 0x00, 0x03,
2274 'f', 'o', 'o', 0x00, 2279 'f', 'o', 'o', 0x00,
2275 0x00, 0x00, 0x03, 'f', 2280 0x00, 0x00, 0x03, 'f',
2276 'o', 'o', 0x00, 0x00, 2281 'o', 'o', 0x00, 0x00,
2277 0x00, 0x03, 'b', 'a', 2282 0x00, 0x03, 'b', 'a',
2278 'r' 2283 'r'
2279 }; 2284 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 0x00, 0x00, 0x00, 0x02, 2319 0x00, 0x00, 0x00, 0x02,
2315 0x00, 0x00, 0x00, 0x03, 2320 0x00, 0x00, 0x00, 0x03,
2316 'b', 'a', 'r', 0x00, 2321 'b', 'a', 'r', 0x00,
2317 0x00, 0x00, 0x03, 'f', 2322 0x00, 0x00, 0x03, 'f',
2318 'o', 'o', 0x00, 0x00, 2323 'o', 'o', 0x00, 0x00,
2319 0x00, 0x03, 'f', 'o', 2324 0x00, 0x03, 'f', 'o',
2320 'o', 0x00, 0x00, 0x00, 2325 'o', 0x00, 0x00, 0x00,
2321 0x00 2326 0x00
2322 }; 2327 };
2323 const unsigned char kV4FrameData[] = { 2328 const unsigned char kV4FrameData[] = {
2324 0x00, 0x25, 0x02, 0x01, 2329 0x00, 0x25, 0x08, 0x01,
2325 0x7f, 0xff, 0xff, 0xff, 2330 0x7f, 0xff, 0xff, 0xff,
2326 0x00, 0x00, 0x00, 0x02, 2331 0x00, 0x00, 0x00, 0x02,
2327 0x00, 0x00, 0x00, 0x03, 2332 0x00, 0x00, 0x00, 0x03,
2328 'b', 'a', 'r', 0x00, 2333 'b', 'a', 'r', 0x00,
2329 0x00, 0x00, 0x03, 'f', 2334 0x00, 0x00, 0x03, 'f',
2330 'o', 'o', 0x00, 0x00, 2335 'o', 'o', 0x00, 0x00,
2331 0x00, 0x03, 'f', 'o', 2336 0x00, 0x03, 'f', 'o',
2332 'o', 0x00, 0x00, 0x00, 2337 'o', 0x00, 0x00, 0x00,
2333 0x00 2338 0x00
2334 }; 2339 };
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 0x66, 0x80, 0x00, 0x4a, 2391 0x66, 0x80, 0x00, 0x4a,
2387 0xcb, 0xcf, 0x07, 0x08, 2392 0xcb, 0xcf, 0x07, 0x08,
2388 0x20, 0x10, 0x95, 0x96, 2393 0x20, 0x10, 0x95, 0x96,
2389 0x9f, 0x0f, 0xa2, 0x00, 2394 0x9f, 0x0f, 0xa2, 0x00,
2390 0x02, 0x28, 0x29, 0xb1, 2395 0x02, 0x28, 0x29, 0xb1,
2391 0x08, 0x20, 0x80, 0x00, 2396 0x08, 0x20, 0x80, 0x00,
2392 0x00, 0x00, 0x00, 0xff, 2397 0x00, 0x00, 0x00, 0xff,
2393 0xff, 2398 0xff,
2394 }; 2399 };
2395 const unsigned char kV4FrameData[] = { 2400 const unsigned char kV4FrameData[] = {
2396 0x00, 0x35, 0x02, 0x00, 2401 0x00, 0x35, 0x08, 0x00,
2397 0x00, 0x00, 0x00, 0x01, 2402 0x00, 0x00, 0x00, 0x01,
2398 0x38, 0xea, 0xe3, 0xc6, 2403 0x38, 0xea, 0xe3, 0xc6,
2399 0xa7, 0xc2, 0x02, 0xe5, 2404 0xa7, 0xc2, 0x02, 0xe5,
2400 0x0e, 0x50, 0xc2, 0x4b, 2405 0x0e, 0x50, 0xc2, 0x4b,
2401 0x4a, 0x04, 0xe5, 0x0b, 2406 0x4a, 0x04, 0xe5, 0x0b,
2402 0x66, 0x80, 0x00, 0x4a, 2407 0x66, 0x80, 0x00, 0x4a,
2403 0xcb, 0xcf, 0x07, 0x08, 2408 0xcb, 0xcf, 0x07, 0x08,
2404 0x20, 0x10, 0x95, 0x96, 2409 0x20, 0x10, 0x95, 0x96,
2405 0x9f, 0x0f, 0xa2, 0x00, 2410 0x9f, 0x0f, 0xa2, 0x00,
2406 0x02, 0x28, 0x29, 0xb1, 2411 0x02, 0x28, 0x29, 0xb1,
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
3127 scoped_ptr<SpdyFrame> control_frame( 3132 scoped_ptr<SpdyFrame> control_frame(
3128 framer.CreateSynReply(1, // stream_id 3133 framer.CreateSynReply(1, // stream_id
3129 CONTROL_FLAG_NONE, 3134 CONTROL_FLAG_NONE,
3130 &headers)); 3135 &headers));
3131 EXPECT_TRUE(control_frame.get() != NULL); 3136 EXPECT_TRUE(control_frame.get() != NULL);
3132 TestSpdyVisitor visitor(spdy_version_); 3137 TestSpdyVisitor visitor(spdy_version_);
3133 visitor.use_compression_ = true; 3138 visitor.use_compression_ = true;
3134 visitor.SimulateInFramer( 3139 visitor.SimulateInFramer(
3135 reinterpret_cast<unsigned char*>(control_frame->data()), 3140 reinterpret_cast<unsigned char*>(control_frame->data()),
3136 control_frame->size()); 3141 control_frame->size());
3137 EXPECT_EQ(1, visitor.syn_reply_frame_count_); 3142 if (IsSpdy4()) {
3143 EXPECT_EQ(0, visitor.syn_reply_frame_count_);
3144 EXPECT_EQ(1, visitor.headers_frame_count_);
3145 } else {
3146 EXPECT_EQ(1, visitor.syn_reply_frame_count_);
3147 EXPECT_EQ(0, visitor.headers_frame_count_);
3148 }
3138 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); 3149 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_));
3139 } 3150 }
3140 3151
3141 TEST_P(SpdyFramerTest, ReadCompressedHeadersHeaderBlock) { 3152 TEST_P(SpdyFramerTest, ReadCompressedHeadersHeaderBlock) {
3142 SpdyHeaderBlock headers; 3153 SpdyHeaderBlock headers;
3143 headers["alpha"] = "beta"; 3154 headers["alpha"] = "beta";
3144 headers["gamma"] = "delta"; 3155 headers["gamma"] = "delta";
3145 SpdyFramer framer(spdy_version_); 3156 SpdyFramer framer(spdy_version_);
3146 scoped_ptr<SpdyFrame> control_frame( 3157 scoped_ptr<SpdyFrame> control_frame(
3147 framer.CreateHeaders(1, // stream_id 3158 framer.CreateHeaders(1, // stream_id
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
4032 SpdyFramer framer(spdy_version_); 4043 SpdyFramer framer(spdy_version_);
4033 framer.set_visitor(&visitor); 4044 framer.set_visitor(&visitor);
4034 framer.set_debug_visitor(&debug_visitor); 4045 framer.set_debug_visitor(&debug_visitor);
4035 4046
4036 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(8, SYN_STREAM, _, _)); 4047 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(8, SYN_STREAM, _, _));
4037 4048
4038 SpdyHeaderBlock headers; 4049 SpdyHeaderBlock headers;
4039 headers["foo"] = "bar"; 4050 headers["foo"] = "bar";
4040 scoped_ptr<SpdyFrame> frame( 4051 scoped_ptr<SpdyFrame> frame(
4041 framer.CreateSynStream(8, 3, 1, 0, CONTROL_FLAG_NONE, &headers)); 4052 framer.CreateSynStream(8, 3, 1, 0, CONTROL_FLAG_NONE, &headers));
4042 SetFrameFlags(frame.get(), flags, spdy_version_); 4053 int set_flags = flags;
4054 if (IsSpdy4()) {
4055 // PRIORITY required for SYN_STREAM simulation.
4056 set_flags |= HEADERS_FLAG_PRIORITY;
4057 }
4058 SetFrameFlags(frame.get(), set_flags, spdy_version_);
4043 4059
4044 if (flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) { 4060 if (!IsSpdy4() &&
4061 flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) {
4062 EXPECT_CALL(visitor, OnError(_));
4063 } else if (IsSpdy4() &&
4064 flags & ~(CONTROL_FLAG_FIN | HEADERS_FLAG_PRIORITY)) {
4045 EXPECT_CALL(visitor, OnError(_)); 4065 EXPECT_CALL(visitor, OnError(_));
4046 } else { 4066 } else {
4047 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(8, SYN_STREAM, _)); 4067 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(8, SYN_STREAM, _));
4048 EXPECT_CALL(visitor, OnSynStream(8, 3, 1, 0, flags & CONTROL_FLAG_FIN, 4068 if (IsSpdy4()) {
4049 flags & CONTROL_FLAG_UNIDIRECTIONAL)); 4069 EXPECT_CALL(visitor, OnSynStream(8, 0, 1, 0, flags & CONTROL_FLAG_FIN,
4070 false));
4071 } else {
4072 EXPECT_CALL(visitor, OnSynStream(8, 3, 1, 0, flags & CONTROL_FLAG_FIN,
4073 flags & CONTROL_FLAG_UNIDIRECTIONAL));
4074 }
4050 EXPECT_CALL(visitor, OnControlFrameHeaderData(8, _, _)) 4075 EXPECT_CALL(visitor, OnControlFrameHeaderData(8, _, _))
4051 .WillRepeatedly(testing::Return(true)); 4076 .WillRepeatedly(testing::Return(true));
4052 if (flags & DATA_FLAG_FIN) { 4077 if (flags & DATA_FLAG_FIN) {
4053 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true)); 4078 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true));
4054 } 4079 }
4055 } 4080 }
4056 4081
4057 framer.ProcessInput(frame->data(), frame->size()); 4082 framer.ProcessInput(frame->data(), frame->size());
4058 if (flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) { 4083 if (!IsSpdy4() &&
4084 flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) {
4059 EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state()); 4085 EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
4060 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS, 4086 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS,
4061 framer.error_code()) 4087 framer.error_code())
4088 << SpdyFramer::ErrorCodeToString(framer.error_code());
4089 } else if (IsSpdy4() &&
4090 flags & ~(CONTROL_FLAG_FIN | HEADERS_FLAG_PRIORITY)) {
4091 EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
4092 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS,
4093 framer.error_code())
4062 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4094 << SpdyFramer::ErrorCodeToString(framer.error_code());
4063 } else { 4095 } else {
4064 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4096 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
4065 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4097 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
4066 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4098 << SpdyFramer::ErrorCodeToString(framer.error_code());
4067 } 4099 }
4068 } 4100 }
4069 } 4101 }
4070 4102
4071 TEST_P(SpdyFramerTest, SynReplyFrameFlags) { 4103 TEST_P(SpdyFramerTest, SynReplyFrameFlags) {
4104 if (IsSpdy4()) {
4105 // Covered by HEADERS case.
4106 return;
4107 }
4072 for (int flags = 0; flags < 256; ++flags) { 4108 for (int flags = 0; flags < 256; ++flags) {
4073 SCOPED_TRACE(testing::Message() << "Flags " << flags); 4109 SCOPED_TRACE(testing::Message() << "Flags " << flags);
4074 4110
4075 testing::StrictMock<test::MockVisitor> visitor; 4111 testing::StrictMock<test::MockVisitor> visitor;
4076 SpdyFramer framer(spdy_version_); 4112 SpdyFramer framer(spdy_version_);
4077 framer.set_visitor(&visitor); 4113 framer.set_visitor(&visitor);
4078 4114
4079 SpdyHeaderBlock headers; 4115 SpdyHeaderBlock headers;
4080 headers["foo"] = "bar"; 4116 headers["foo"] = "bar";
4081 scoped_ptr<SpdyFrame> frame( 4117 scoped_ptr<SpdyFrame> frame(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4201 } else { 4237 } else {
4202 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4238 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
4203 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4239 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
4204 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4240 << SpdyFramer::ErrorCodeToString(framer.error_code());
4205 } 4241 }
4206 } 4242 }
4207 } 4243 }
4208 4244
4209 TEST_P(SpdyFramerTest, HeadersFrameFlags) { 4245 TEST_P(SpdyFramerTest, HeadersFrameFlags) {
4210 for (int flags = 0; flags < 256; ++flags) { 4246 for (int flags = 0; flags < 256; ++flags) {
4247 if (IsSpdy4() && flags & HEADERS_FLAG_PRIORITY) {
4248 // Covered by SYN_STREAM case.
4249 continue;
4250 }
4211 SCOPED_TRACE(testing::Message() << "Flags " << flags); 4251 SCOPED_TRACE(testing::Message() << "Flags " << flags);
4212 4252
4213 testing::StrictMock<test::MockVisitor> visitor; 4253 testing::StrictMock<test::MockVisitor> visitor;
4214 SpdyFramer framer(spdy_version_); 4254 SpdyFramer framer(spdy_version_);
4215 framer.set_visitor(&visitor); 4255 framer.set_visitor(&visitor);
4216 4256
4217 SpdyHeaderBlock headers; 4257 SpdyHeaderBlock headers;
4218 headers["foo"] = "bar"; 4258 headers["foo"] = "bar";
4219 scoped_ptr<SpdyFrame> frame( 4259 scoped_ptr<SpdyFrame> frame(
4220 framer.CreateHeaders(57, CONTROL_FLAG_NONE, &headers)); 4260 framer.CreateHeaders(57, CONTROL_FLAG_NONE, &headers));
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
4552 SpdyBlockedIR blocked_ir(0); 4592 SpdyBlockedIR blocked_ir(0);
4553 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); 4593 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir));
4554 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); 4594 framer.ProcessInput(frame->data(), framer.GetBlockedSize());
4555 4595
4556 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4596 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
4557 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4597 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
4558 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4598 << SpdyFramer::ErrorCodeToString(framer.error_code());
4559 } 4599 }
4560 4600
4561 } // namespace net 4601 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698