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

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

Issue 9802003: SPDY - persist SPDY settings. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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_network_transaction_spdy2_unittest.cc ('k') | net/spdy/spdy_protocol.h » ('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 "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); 929 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3));
930 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); 930 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, false));
931 scoped_ptr<SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); 931 scoped_ptr<SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true));
932 932
933 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, LOWEST)); 933 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, LOWEST));
934 scoped_ptr<SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 5)); 934 scoped_ptr<SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 5));
935 scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(5, false)); 935 scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(5, false));
936 scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(5, true)); 936 scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(5, true));
937 937
938 SpdySettings settings; 938 SpdySettings settings;
939 SettingsFlagsAndId id(0, SETTINGS_MAX_CONCURRENT_STREAMS); 939 SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS);
940 const size_t max_concurrent_streams = 1; 940 const size_t max_concurrent_streams = 1;
941 941
942 settings.push_back(SpdySetting(id, max_concurrent_streams)); 942 settings.push_back(SpdySetting(id, max_concurrent_streams));
943 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); 943 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings));
944 944
945 MockWrite writes[] = { 945 MockWrite writes[] = {
946 CreateMockWrite(*req), 946 CreateMockWrite(*req),
947 CreateMockWrite(*req2), 947 CreateMockWrite(*req2),
948 CreateMockWrite(*req3), 948 CreateMockWrite(*req3),
949 }; 949 };
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 scoped_ptr<SpdyFrame> req4( 1065 scoped_ptr<SpdyFrame> req4(
1066 ConstructSpdyGet(NULL, 0, false, 5, HIGHEST)); 1066 ConstructSpdyGet(NULL, 0, false, 5, HIGHEST));
1067 scoped_ptr<SpdyFrame> resp4(ConstructSpdyGetSynReply(NULL, 0, 5)); 1067 scoped_ptr<SpdyFrame> resp4(ConstructSpdyGetSynReply(NULL, 0, 5));
1068 scoped_ptr<SpdyFrame> fbody4(ConstructSpdyBodyFrame(5, true)); 1068 scoped_ptr<SpdyFrame> fbody4(ConstructSpdyBodyFrame(5, true));
1069 1069
1070 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 7, LOWEST)); 1070 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 7, LOWEST));
1071 scoped_ptr<SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 7)); 1071 scoped_ptr<SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 7));
1072 scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(7, false)); 1072 scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(7, false));
1073 scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(7, true)); 1073 scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(7, true));
1074 1074
1075
1076 SpdySettings settings; 1075 SpdySettings settings;
1077 SettingsFlagsAndId id(0, SETTINGS_MAX_CONCURRENT_STREAMS); 1076 SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS);
1078 const size_t max_concurrent_streams = 1; 1077 const size_t max_concurrent_streams = 1;
1079 1078
1080 settings.push_back(SpdySetting(id, max_concurrent_streams)); 1079 settings.push_back(SpdySetting(id, max_concurrent_streams));
1081 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); 1080 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings));
1082 1081
1083 MockWrite writes[] = { CreateMockWrite(*req), 1082 MockWrite writes[] = { CreateMockWrite(*req),
1084 CreateMockWrite(*req2), 1083 CreateMockWrite(*req2),
1085 CreateMockWrite(*req4), 1084 CreateMockWrite(*req4),
1086 CreateMockWrite(*req3), 1085 CreateMockWrite(*req3),
1087 }; 1086 };
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 TestCompletionCallback callback4; 1133 TestCompletionCallback callback4;
1135 1134
1136 HttpRequestInfo httpreq1 = CreateGetRequest(); 1135 HttpRequestInfo httpreq1 = CreateGetRequest();
1137 HttpRequestInfo httpreq2 = CreateGetRequest(); 1136 HttpRequestInfo httpreq2 = CreateGetRequest();
1138 HttpRequestInfo httpreq3 = CreateGetRequest(); 1137 HttpRequestInfo httpreq3 = CreateGetRequest();
1139 HttpRequestInfo httpreq4 = CreateGetRequest(); 1138 HttpRequestInfo httpreq4 = CreateGetRequest();
1140 httpreq4.priority = HIGHEST; 1139 httpreq4.priority = HIGHEST;
1141 1140
1142 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); 1141 out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
1143 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1142 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1144 // run transaction 1 through quickly to force a read of our SETTINGS 1143 // Run transaction 1 through quickly to force a read of our SETTINGS frame.
1145 // frame
1146 out.rv = callback1.WaitForResult(); 1144 out.rv = callback1.WaitForResult();
1147 ASSERT_EQ(OK, out.rv); 1145 ASSERT_EQ(OK, out.rv);
1148 1146
1149 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); 1147 out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
1150 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1148 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1151 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); 1149 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
1152 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1150 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1153 out.rv = trans4->Start(&httpreq4, callback4.callback(), log); 1151 out.rv = trans4->Start(&httpreq4, callback4.callback(), log);
1154 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1152 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1155 1153
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 1209 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
1212 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); 1210 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, false));
1213 scoped_ptr<SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); 1211 scoped_ptr<SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true));
1214 1212
1215 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); 1213 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST));
1216 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); 1214 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3));
1217 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); 1215 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, false));
1218 scoped_ptr<SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); 1216 scoped_ptr<SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true));
1219 1217
1220 SpdySettings settings; 1218 SpdySettings settings;
1221 SettingsFlagsAndId id(0, SETTINGS_MAX_CONCURRENT_STREAMS); 1219 SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS);
1222 const size_t max_concurrent_streams = 1; 1220 const size_t max_concurrent_streams = 1;
1223 1221
1224 settings.push_back(SpdySetting(id, max_concurrent_streams)); 1222 settings.push_back(SpdySetting(id, max_concurrent_streams));
1225 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); 1223 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings));
1226 1224
1227 MockWrite writes[] = { CreateMockWrite(*req), 1225 MockWrite writes[] = { CreateMockWrite(*req),
1228 CreateMockWrite(*req2), 1226 CreateMockWrite(*req2),
1229 }; 1227 };
1230 MockRead reads[] = { 1228 MockRead reads[] = {
1231 CreateMockRead(*settings_frame, 1), 1229 CreateMockRead(*settings_frame, 1),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 TestCompletionCallback callback1; 1262 TestCompletionCallback callback1;
1265 TestCompletionCallback callback2; 1263 TestCompletionCallback callback2;
1266 TestCompletionCallback callback3; 1264 TestCompletionCallback callback3;
1267 1265
1268 HttpRequestInfo httpreq1 = CreateGetRequest(); 1266 HttpRequestInfo httpreq1 = CreateGetRequest();
1269 HttpRequestInfo httpreq2 = CreateGetRequest(); 1267 HttpRequestInfo httpreq2 = CreateGetRequest();
1270 HttpRequestInfo httpreq3 = CreateGetRequest(); 1268 HttpRequestInfo httpreq3 = CreateGetRequest();
1271 1269
1272 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); 1270 out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
1273 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1271 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1274 // run transaction 1 through quickly to force a read of our SETTINGS 1272 // Run transaction 1 through quickly to force a read of our SETTINGS frame.
1275 // frame
1276 out.rv = callback1.WaitForResult(); 1273 out.rv = callback1.WaitForResult();
1277 ASSERT_EQ(OK, out.rv); 1274 ASSERT_EQ(OK, out.rv);
1278 1275
1279 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); 1276 out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
1280 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1277 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1281 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); 1278 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
1282 delete trans3.release(); 1279 delete trans3.release();
1283 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1280 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1284 out.rv = callback2.WaitForResult(); 1281 out.rv = callback2.WaitForResult();
1285 ASSERT_EQ(OK, out.rv); 1282 ASSERT_EQ(OK, out.rv);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 // Construct the request. 1343 // Construct the request.
1347 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1344 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1348 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 1345 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
1349 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); 1346 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, false));
1350 scoped_ptr<SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); 1347 scoped_ptr<SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true));
1351 1348
1352 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); 1349 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST));
1353 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); 1350 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3));
1354 1351
1355 SpdySettings settings; 1352 SpdySettings settings;
1356 SettingsFlagsAndId id(0, SETTINGS_MAX_CONCURRENT_STREAMS); 1353 SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS);
1357 const size_t max_concurrent_streams = 1; 1354 const size_t max_concurrent_streams = 1;
1358 1355
1359 settings.push_back(SpdySetting(id, max_concurrent_streams)); 1356 settings.push_back(SpdySetting(id, max_concurrent_streams));
1360 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); 1357 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings));
1361 1358
1362 MockWrite writes[] = { CreateMockWrite(*req), 1359 MockWrite writes[] = { CreateMockWrite(*req),
1363 CreateMockWrite(*req2), 1360 CreateMockWrite(*req2),
1364 }; 1361 };
1365 MockRead reads[] = { 1362 MockRead reads[] = {
1366 CreateMockRead(*settings_frame, 1), 1363 CreateMockRead(*settings_frame, 1),
(...skipping 27 matching lines...) Expand all
1394 TestCompletionCallback callback1; 1391 TestCompletionCallback callback1;
1395 TestCompletionCallback callback2; 1392 TestCompletionCallback callback2;
1396 KillerCallback callback3(trans3); 1393 KillerCallback callback3(trans3);
1397 1394
1398 HttpRequestInfo httpreq1 = CreateGetRequest(); 1395 HttpRequestInfo httpreq1 = CreateGetRequest();
1399 HttpRequestInfo httpreq2 = CreateGetRequest(); 1396 HttpRequestInfo httpreq2 = CreateGetRequest();
1400 HttpRequestInfo httpreq3 = CreateGetRequest(); 1397 HttpRequestInfo httpreq3 = CreateGetRequest();
1401 1398
1402 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); 1399 out.rv = trans1.Start(&httpreq1, callback1.callback(), log);
1403 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1400 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1404 // run transaction 1 through quickly to force a read of our SETTINGS 1401 // Run transaction 1 through quickly to force a read of our SETTINGS frame.
1405 // frame
1406 out.rv = callback1.WaitForResult(); 1402 out.rv = callback1.WaitForResult();
1407 ASSERT_EQ(OK, out.rv); 1403 ASSERT_EQ(OK, out.rv);
1408 1404
1409 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); 1405 out.rv = trans2.Start(&httpreq2, callback2.callback(), log);
1410 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1406 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1411 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); 1407 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
1412 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1408 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1413 out.rv = callback3.WaitForResult(); 1409 out.rv = callback3.WaitForResult();
1414 ASSERT_EQ(ERR_ABORTED, out.rv); 1410 ASSERT_EQ(ERR_ABORTED, out.rv);
1415 1411
(...skipping 20 matching lines...) Expand all
1436 1432
1437 // Test that a simple PUT request works. 1433 // Test that a simple PUT request works.
1438 TEST_P(SpdyNetworkTransactionSpdy3Test, Put) { 1434 TEST_P(SpdyNetworkTransactionSpdy3Test, Put) {
1439 // Setup the request 1435 // Setup the request
1440 HttpRequestInfo request; 1436 HttpRequestInfo request;
1441 request.method = "PUT"; 1437 request.method = "PUT";
1442 request.url = GURL("http://www.google.com/"); 1438 request.url = GURL("http://www.google.com/");
1443 1439
1444 const SpdyHeaderInfo kSynStartHeader = { 1440 const SpdyHeaderInfo kSynStartHeader = {
1445 SYN_STREAM, // Kind = Syn 1441 SYN_STREAM, // Kind = Syn
1446 1, // Stream ID 1442 1, // Stream ID
1447 0, // Associated stream ID 1443 0, // Associated stream ID
1448 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1444 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1449 0, // Credential Slot 1445 0, // Credential Slot
1450 CONTROL_FLAG_FIN, // Control Flags 1446 CONTROL_FLAG_FIN, // Control Flags
1451 false, // Compressed 1447 false, // Compressed
1452 INVALID, // Status 1448 INVALID, // Status
1453 NULL, // Data 1449 NULL, // Data
1454 0, // Length 1450 0, // Length
1455 DATA_FLAG_NONE // Data Flags 1451 DATA_FLAG_NONE // Data Flags
1456 }; 1452 };
1457 const char* const kPutHeaders[] = { 1453 const char* const kPutHeaders[] = {
1458 ":method", "PUT", 1454 ":method", "PUT",
1459 ":path", "/", 1455 ":path", "/",
1460 ":host", "www.google.com", 1456 ":host", "www.google.com",
1461 ":scheme", "http", 1457 ":scheme", "http",
1462 ":version", "HTTP/1.1", 1458 ":version", "HTTP/1.1",
1463 "content-length", "0" 1459 "content-length", "0"
1464 }; 1460 };
1465 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, 1461 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0,
1466 kPutHeaders, arraysize(kPutHeaders) / 2)); 1462 kPutHeaders, arraysize(kPutHeaders) / 2));
1467 MockWrite writes[] = { 1463 MockWrite writes[] = {
1468 CreateMockWrite(*req) 1464 CreateMockWrite(*req)
1469 }; 1465 };
1470 1466
1471 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1467 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1472 const SpdyHeaderInfo kSynReplyHeader = { 1468 const SpdyHeaderInfo kSynReplyHeader = {
1473 SYN_REPLY, // Kind = SynReply 1469 SYN_REPLY, // Kind = SynReply
1474 1, // Stream ID 1470 1, // Stream ID
1475 0, // Associated stream ID 1471 0, // Associated stream ID
1476 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1472 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1477 0, // Credential Slot 1473 0, // Credential Slot
1478 CONTROL_FLAG_NONE, // Control Flags 1474 CONTROL_FLAG_NONE, // Control Flags
1479 false, // Compressed 1475 false, // Compressed
1480 INVALID, // Status 1476 INVALID, // Status
1481 NULL, // Data 1477 NULL, // Data
1482 0, // Length 1478 0, // Length
1483 DATA_FLAG_NONE // Data Flags 1479 DATA_FLAG_NONE // Data Flags
1484 }; 1480 };
1485 static const char* const kStandardGetHeaders[] = { 1481 static const char* const kStandardGetHeaders[] = {
1486 "status", "200", 1482 "status", "200",
1487 "version", "HTTP/1.1" 1483 "version", "HTTP/1.1"
1488 "content-length", "1234" 1484 "content-length", "1234"
1489 }; 1485 };
1490 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, 1486 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader,
1491 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); 1487 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2));
1492 MockRead reads[] = { 1488 MockRead reads[] = {
(...skipping 16 matching lines...) Expand all
1509 1505
1510 // Test that a simple HEAD request works. 1506 // Test that a simple HEAD request works.
1511 TEST_P(SpdyNetworkTransactionSpdy3Test, Head) { 1507 TEST_P(SpdyNetworkTransactionSpdy3Test, Head) {
1512 // Setup the request 1508 // Setup the request
1513 HttpRequestInfo request; 1509 HttpRequestInfo request;
1514 request.method = "HEAD"; 1510 request.method = "HEAD";
1515 request.url = GURL("http://www.google.com/"); 1511 request.url = GURL("http://www.google.com/");
1516 1512
1517 const SpdyHeaderInfo kSynStartHeader = { 1513 const SpdyHeaderInfo kSynStartHeader = {
1518 SYN_STREAM, // Kind = Syn 1514 SYN_STREAM, // Kind = Syn
1519 1, // Stream ID 1515 1, // Stream ID
1520 0, // Associated stream ID 1516 0, // Associated stream ID
1521 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1517 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1522 0, // Credential Slot 1518 0, // Credential Slot
1523 CONTROL_FLAG_FIN, // Control Flags 1519 CONTROL_FLAG_FIN, // Control Flags
1524 false, // Compressed 1520 false, // Compressed
1525 INVALID, // Status 1521 INVALID, // Status
1526 NULL, // Data 1522 NULL, // Data
1527 0, // Length 1523 0, // Length
1528 DATA_FLAG_NONE // Data Flags 1524 DATA_FLAG_NONE // Data Flags
1529 }; 1525 };
1530 const char* const kHeadHeaders[] = { 1526 const char* const kHeadHeaders[] = {
1531 ":method", "HEAD", 1527 ":method", "HEAD",
1532 ":path", "/", 1528 ":path", "/",
1533 ":host", "www.google.com", 1529 ":host", "www.google.com",
1534 ":scheme", "http", 1530 ":scheme", "http",
1535 ":version", "HTTP/1.1", 1531 ":version", "HTTP/1.1",
1536 "content-length", "0" 1532 "content-length", "0"
1537 }; 1533 };
1538 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, 1534 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0,
1539 kHeadHeaders, arraysize(kHeadHeaders) / 2)); 1535 kHeadHeaders, arraysize(kHeadHeaders) / 2));
1540 MockWrite writes[] = { 1536 MockWrite writes[] = {
1541 CreateMockWrite(*req) 1537 CreateMockWrite(*req)
1542 }; 1538 };
1543 1539
1544 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1540 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1545 const SpdyHeaderInfo kSynReplyHeader = { 1541 const SpdyHeaderInfo kSynReplyHeader = {
1546 SYN_REPLY, // Kind = SynReply 1542 SYN_REPLY, // Kind = SynReply
1547 1, // Stream ID 1543 1, // Stream ID
1548 0, // Associated stream ID 1544 0, // Associated stream ID
1549 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1545 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
1550 0, // Credential Slot 1546 0, // Credential Slot
1551 CONTROL_FLAG_NONE, // Control Flags 1547 CONTROL_FLAG_NONE, // Control Flags
1552 false, // Compressed 1548 false, // Compressed
1553 INVALID, // Status 1549 INVALID, // Status
1554 NULL, // Data 1550 NULL, // Data
1555 0, // Length 1551 0, // Length
1556 DATA_FLAG_NONE // Data Flags 1552 DATA_FLAG_NONE // Data Flags
1557 }; 1553 };
1558 static const char* const kStandardGetHeaders[] = { 1554 static const char* const kStandardGetHeaders[] = {
1559 "status", "200", 1555 "status", "200",
1560 "version", "HTTP/1.1" 1556 "version", "HTTP/1.1"
1561 "content-length", "1234" 1557 "content-length", "1234"
1562 }; 1558 };
1563 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, 1559 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader,
1564 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); 1560 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2));
1565 MockRead reads[] = { 1561 MockRead reads[] = {
(...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after
3472 } 3468 }
3473 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines); 3469 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines);
3474 } 3470 }
3475 } 3471 }
3476 3472
3477 // Verify that various SynReply headers parse vary fields correctly 3473 // Verify that various SynReply headers parse vary fields correctly
3478 // through the HTTP layer, and the response matches the request. 3474 // through the HTTP layer, and the response matches the request.
3479 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyHeadersVary) { 3475 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyHeadersVary) {
3480 static const SpdyHeaderInfo syn_reply_info = { 3476 static const SpdyHeaderInfo syn_reply_info = {
3481 SYN_REPLY, // Syn Reply 3477 SYN_REPLY, // Syn Reply
3482 1, // Stream ID 3478 1, // Stream ID
3483 0, // Associated Stream ID 3479 0, // Associated Stream ID
3484 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 3480 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
3485 // Priority 3481 0, // Credential Slot
3486 0, // Credential Slot
3487 CONTROL_FLAG_NONE, // Control Flags 3482 CONTROL_FLAG_NONE, // Control Flags
3488 false, // Compressed 3483 false, // Compressed
3489 INVALID, // Status 3484 INVALID, // Status
3490 NULL, // Data 3485 NULL, // Data
3491 0, // Data Length 3486 0, // Data Length
3492 DATA_FLAG_NONE // Data Flags 3487 DATA_FLAG_NONE // Data Flags
3493 }; 3488 };
3494 // Modify the following data to change/add test cases: 3489 // Modify the following data to change/add test cases:
3495 struct SynReplyTests { 3490 struct SynReplyTests {
3496 const SpdyHeaderInfo* syn_reply; 3491 const SpdyHeaderInfo* syn_reply;
3497 bool vary_matches; 3492 bool vary_matches;
3498 int num_headers[2]; 3493 int num_headers[2];
3499 const char* extra_headers[2][16]; 3494 const char* extra_headers[2][16];
3500 } test_cases[] = { 3495 } test_cases[] = {
3501 // Test the case of a multi-valued cookie. When the value is delimited 3496 // Test the case of a multi-valued cookie. When the value is delimited
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 256); 3637 256);
3643 3638
3644 EXPECT_EQ(std::string(reply_buffer), lines) << i; 3639 EXPECT_EQ(std::string(reply_buffer), lines) << i;
3645 } 3640 }
3646 } 3641 }
3647 3642
3648 // Verify that we don't crash on invalid SynReply responses. 3643 // Verify that we don't crash on invalid SynReply responses.
3649 TEST_P(SpdyNetworkTransactionSpdy3Test, InvalidSynReply) { 3644 TEST_P(SpdyNetworkTransactionSpdy3Test, InvalidSynReply) {
3650 const SpdyHeaderInfo kSynStartHeader = { 3645 const SpdyHeaderInfo kSynStartHeader = {
3651 SYN_REPLY, // Kind = SynReply 3646 SYN_REPLY, // Kind = SynReply
3652 1, // Stream ID 3647 1, // Stream ID
3653 0, // Associated stream ID 3648 0, // Associated stream ID
3654 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 3649 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
3655 // Priority 3650 0, // Credential Slot
3656 0, // Credential Slot
3657 CONTROL_FLAG_NONE, // Control Flags 3651 CONTROL_FLAG_NONE, // Control Flags
3658 false, // Compressed 3652 false, // Compressed
3659 INVALID, // Status 3653 INVALID, // Status
3660 NULL, // Data 3654 NULL, // Data
3661 0, // Length 3655 0, // Length
3662 DATA_FLAG_NONE // Data Flags 3656 DATA_FLAG_NONE // Data Flags
3663 }; 3657 };
3664 3658
3665 struct InvalidSynReplyTests { 3659 struct InvalidSynReplyTests {
3666 int num_headers; 3660 int num_headers;
3667 const char* headers[10]; 3661 const char* headers[10];
3668 } test_cases[] = { 3662 } test_cases[] = {
3669 // SYN_REPLY missing status header 3663 // SYN_REPLY missing status header
3670 { 4, 3664 { 4,
3671 { "cookie", "val1", 3665 { "cookie", "val1",
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
4364 4358
4365 // Verify that we consumed all test data. 4359 // Verify that we consumed all test data.
4366 helper.VerifyDataConsumed(); 4360 helper.VerifyDataConsumed();
4367 } 4361 }
4368 4362
4369 // Test that if the server requests persistence of settings, that we save 4363 // Test that if the server requests persistence of settings, that we save
4370 // the settings in the SpdySettingsStorage. 4364 // the settings in the SpdySettingsStorage.
4371 TEST_P(SpdyNetworkTransactionSpdy3Test, SettingsSaved) { 4365 TEST_P(SpdyNetworkTransactionSpdy3Test, SettingsSaved) {
4372 static const SpdyHeaderInfo kSynReplyInfo = { 4366 static const SpdyHeaderInfo kSynReplyInfo = {
4373 SYN_REPLY, // Syn Reply 4367 SYN_REPLY, // Syn Reply
4374 1, // Stream ID 4368 1, // Stream ID
4375 0, // Associated Stream ID 4369 0, // Associated Stream ID
4376 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 4370 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
4377 // Priority 4371 0, // Credential Slot
4378 0, // Credential Slot
4379 CONTROL_FLAG_NONE, // Control Flags 4372 CONTROL_FLAG_NONE, // Control Flags
4380 false, // Compressed 4373 false, // Compressed
4381 INVALID, // Status 4374 INVALID, // Status
4382 NULL, // Data 4375 NULL, // Data
4383 0, // Data Length 4376 0, // Data Length
4384 DATA_FLAG_NONE // Data Flags 4377 DATA_FLAG_NONE // Data Flags
4385 }; 4378 };
4386 static const char* const kExtraHeaders[] = { 4379 static const char* const kExtraHeaders[] = {
4387 "status", "200", 4380 "status", "200",
4388 "version", "HTTP/1.1" 4381 "version", "HTTP/1.1"
4389 }; 4382 };
4390 4383
4391 BoundNetLog net_log; 4384 BoundNetLog net_log;
4392 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); 4385 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam());
4393 helper.RunPreTestSetup(); 4386 helper.RunPreTestSetup();
4394 4387
4395 // Verify that no settings exist initially. 4388 // Verify that no settings exist initially.
4396 HostPortPair host_port_pair("www.google.com", helper.port()); 4389 HostPortPair host_port_pair("www.google.com", helper.port());
4397 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); 4390 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
4398 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( 4391 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings(
4399 host_port_pair).empty()); 4392 host_port_pair).empty());
4400 4393
4401 // Construct the request. 4394 // Construct the request.
4402 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4395 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4403 MockWrite writes[] = { CreateMockWrite(*req) }; 4396 MockWrite writes[] = { CreateMockWrite(*req) };
4404 4397
4405 // Construct the reply. 4398 // Construct the reply.
4406 scoped_ptr<SpdyFrame> reply( 4399 scoped_ptr<SpdyFrame> reply(
4407 ConstructSpdyPacket(kSynReplyInfo, 4400 ConstructSpdyPacket(kSynReplyInfo,
4408 kExtraHeaders, 4401 kExtraHeaders,
4409 arraysize(kExtraHeaders) / 2, 4402 arraysize(kExtraHeaders) / 2,
4410 NULL, 4403 NULL,
4411 0)); 4404 0));
4412 4405
4413 unsigned int kSampleId1 = 0x1; 4406 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH;
4414 unsigned int kSampleValue1 = 0x0a0a0a0a; 4407 unsigned int kSampleValue1 = 0x0a0a0a0a;
4415 unsigned int kSampleId2 = 0x2; 4408 const SpdySettingsIds kSampleId2 = SETTINGS_DOWNLOAD_BANDWIDTH;
4416 unsigned int kSampleValue2 = 0x0b0b0b0b; 4409 unsigned int kSampleValue2 = 0x0b0b0b0b;
4417 unsigned int kSampleId3 = 0x3; 4410 const SpdySettingsIds kSampleId3 = SETTINGS_ROUND_TRIP_TIME;
4418 unsigned int kSampleValue3 = 0x0c0c0c0c; 4411 unsigned int kSampleValue3 = 0x0c0c0c0c;
4419 scoped_ptr<SpdyFrame> settings_frame; 4412 scoped_ptr<SpdyFrame> settings_frame;
4420 { 4413 {
4421 // Construct the SETTINGS frame. 4414 // Construct the SETTINGS frame.
4422 SpdySettings settings; 4415 SpdySettings settings;
4423 // First add a persisted setting 4416 // First add a persisted setting.
4424 SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST, 4417 SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId1);
4425 kSampleId1);
4426 settings.push_back(std::make_pair(setting1, kSampleValue1)); 4418 settings.push_back(std::make_pair(setting1, kSampleValue1));
4427 // Next add a non-persisted setting 4419 // Next add a non-persisted setting.
4428 SettingsFlagsAndId setting2(0, kSampleId2); 4420 SettingsFlagsAndId setting2(SETTINGS_FLAG_NONE, kSampleId2);
4429 settings.push_back(std::make_pair(setting2, kSampleValue2)); 4421 settings.push_back(std::make_pair(setting2, kSampleValue2));
4430 // Next add another persisted setting 4422 // Next add another persisted setting.
4431 SettingsFlagsAndId setting3(SETTINGS_FLAG_PLEASE_PERSIST, 4423 SettingsFlagsAndId setting3(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId3);
4432 kSampleId3);
4433 settings.push_back(std::make_pair(setting3, kSampleValue3)); 4424 settings.push_back(std::make_pair(setting3, kSampleValue3));
4434 settings_frame.reset(ConstructSpdySettings(settings)); 4425 settings_frame.reset(ConstructSpdySettings(settings));
4435 } 4426 }
4436 4427
4437 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 4428 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
4438 MockRead reads[] = { 4429 MockRead reads[] = {
4439 CreateMockRead(*reply), 4430 CreateMockRead(*reply),
4440 CreateMockRead(*body), 4431 CreateMockRead(*body),
4441 CreateMockRead(*settings_frame), 4432 CreateMockRead(*settings_frame),
4442 MockRead(ASYNC, 0, 0) // EOF 4433 MockRead(ASYNC, 0, 0) // EOF
4443 }; 4434 };
4444 4435
4445 scoped_ptr<DelayedSocketData> data( 4436 scoped_ptr<DelayedSocketData> data(
4446 new DelayedSocketData(1, reads, arraysize(reads), 4437 new DelayedSocketData(1, reads, arraysize(reads),
4447 writes, arraysize(writes))); 4438 writes, arraysize(writes)));
4448 helper.AddData(data.get()); 4439 helper.AddData(data.get());
4449 helper.RunDefaultTest(); 4440 helper.RunDefaultTest();
4450 helper.VerifyDataConsumed(); 4441 helper.VerifyDataConsumed();
4451 TransactionHelperResult out = helper.output(); 4442 TransactionHelperResult out = helper.output();
4452 EXPECT_EQ(OK, out.rv); 4443 EXPECT_EQ(OK, out.rv);
4453 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 4444 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
4454 EXPECT_EQ("hello!", out.response_data); 4445 EXPECT_EQ("hello!", out.response_data);
4455 4446
4456 // TODO(rtenneti): Persist spdy settings.
4457 #ifdef PERSIST_SPDY_SETTINGS
4458 { 4447 {
4459 // Verify we had two persisted settings. 4448 // Verify we had two persisted settings.
4460 SpdySettings saved_settings = 4449 const SettingsMap& settings_map =
4461 spdy_session_pool->http_server_properties()->GetSpdySettings( 4450 spdy_session_pool->http_server_properties()->GetSpdySettings(
4462 host_port_pair); 4451 host_port_pair);
4463 ASSERT_EQ(2u, saved_settings.size()); 4452 ASSERT_EQ(2u, settings_map.size());
4464 4453
4465 // Verify the first persisted setting. 4454 // Verify the first persisted setting.
4466 SpdySetting setting = saved_settings.front(); 4455 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1);
4467 saved_settings.pop_front(); 4456 EXPECT_TRUE(it1 != settings_map.end());
4468 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); 4457 SettingsFlagsAndValue flags_and_value1 = it1->second;
4469 EXPECT_EQ(kSampleId1, setting.first.id()); 4458 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first);
4470 EXPECT_EQ(kSampleValue1, setting.second); 4459 EXPECT_EQ(kSampleValue1, flags_and_value1.second);
4471 4460
4472 // Verify the second persisted setting. 4461 // Verify the second persisted setting.
4473 setting = saved_settings.front(); 4462 SettingsMap::const_iterator it3 = settings_map.find(kSampleId3);
4474 saved_settings.pop_front(); 4463 EXPECT_TRUE(it3 != settings_map.end());
4475 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); 4464 SettingsFlagsAndValue flags_and_value3 = it3->second;
4476 EXPECT_EQ(kSampleId3, setting.first.id()); 4465 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first);
4477 EXPECT_EQ(kSampleValue3, setting.second); 4466 EXPECT_EQ(kSampleValue3, flags_and_value3.second);
4478 } 4467 }
4479 #endif
4480 } 4468 }
4481 4469
4482 // Test that when there are settings saved that they are sent back to the 4470 // Test that when there are settings saved that they are sent back to the
4483 // server upon session establishment. 4471 // server upon session establishment.
4484 TEST_P(SpdyNetworkTransactionSpdy3Test, SettingsPlayback) { 4472 TEST_P(SpdyNetworkTransactionSpdy3Test, SettingsPlayback) {
4485 static const SpdyHeaderInfo kSynReplyInfo = { 4473 static const SpdyHeaderInfo kSynReplyInfo = {
4486 SYN_REPLY, // Syn Reply 4474 SYN_REPLY, // Syn Reply
4487 1, // Stream ID 4475 1, // Stream ID
4488 0, // Associated Stream ID 4476 0, // Associated Stream ID
4489 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 4477 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
4490 // Priority 4478 0, // Credential Slot
4491 0, // Credential Slot
4492 CONTROL_FLAG_NONE, // Control Flags 4479 CONTROL_FLAG_NONE, // Control Flags
4493 false, // Compressed 4480 false, // Compressed
4494 INVALID, // Status 4481 INVALID, // Status
4495 NULL, // Data 4482 NULL, // Data
4496 0, // Data Length 4483 0, // Data Length
4497 DATA_FLAG_NONE // Data Flags 4484 DATA_FLAG_NONE // Data Flags
4498 }; 4485 };
4499 static const char* kExtraHeaders[] = { 4486 static const char* kExtraHeaders[] = {
4500 "status", "200", 4487 "status", "200",
4501 "version", "HTTP/1.1" 4488 "version", "HTTP/1.1"
4502 }; 4489 };
4503 4490
4504 BoundNetLog net_log; 4491 BoundNetLog net_log;
4505 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); 4492 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam());
4506 helper.RunPreTestSetup(); 4493 helper.RunPreTestSetup();
4507 4494
4508 // Verify that no settings exist initially. 4495 // Verify that no settings exist initially.
4509 HostPortPair host_port_pair("www.google.com", helper.port()); 4496 HostPortPair host_port_pair("www.google.com", helper.port());
4510 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); 4497 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
4511 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( 4498 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings(
4512 host_port_pair).empty()); 4499 host_port_pair).empty());
4513 4500
4514 unsigned int kSampleId1 = 0x1; 4501 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH;
4515 unsigned int kSampleValue1 = 0x0a0a0a0a; 4502 unsigned int kSampleValue1 = 0x0a0a0a0a;
4516 unsigned int kSampleId2 = 0xababab; 4503 const SpdySettingsIds kSampleId2 = SETTINGS_ROUND_TRIP_TIME;
4517 unsigned int kSampleValue2 = 0x0c0c0c0c; 4504 unsigned int kSampleValue2 = 0x0c0c0c0c;
4518 // Manually insert settings into the SpdySettingsStorage here.
4519 {
4520 SpdySettings settings;
4521 // First add a persisted setting
4522 SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST,
4523 kSampleId1);
4524 settings.push_back(std::make_pair(setting1, kSampleValue1));
4525 // Next add another persisted setting
4526 SettingsFlagsAndId setting2(SETTINGS_FLAG_PLEASE_PERSIST,
4527 kSampleId2);
4528 settings.push_back(std::make_pair(setting2, kSampleValue2));
4529 4505
4530 spdy_session_pool->http_server_properties()->SetSpdySettings( 4506 // First add a persisted setting.
4531 host_port_pair, settings); 4507 spdy_session_pool->http_server_properties()->SetSpdySetting(
4532 } 4508 host_port_pair,
4509 kSampleId1,
4510 SETTINGS_FLAG_PLEASE_PERSIST,
4511 kSampleValue1);
4512
4513 // Next add another persisted setting.
4514 spdy_session_pool->http_server_properties()->SetSpdySetting(
4515 host_port_pair,
4516 kSampleId2,
4517 SETTINGS_FLAG_PLEASE_PERSIST,
4518 kSampleValue2);
4533 4519
4534 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( 4520 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings(
4535 host_port_pair).size()); 4521 host_port_pair).size());
4536 4522
4537 // Construct the SETTINGS frame. 4523 // Construct the SETTINGS frame.
4538 const SpdySettings& settings = 4524 const SettingsMap& settings_map =
4539 spdy_session_pool->http_server_properties()->GetSpdySettings( 4525 spdy_session_pool->http_server_properties()->GetSpdySettings(
4540 host_port_pair); 4526 host_port_pair);
4527
4528 SpdySettings settings;
4529 for (SettingsMap::const_iterator i = settings_map.begin(),
4530 end = settings_map.end(); i != end; ++i) {
4531 const SpdySettingsIds id = i->first;
4532 const SpdySettingsFlags flags = i->second.first;
4533 const uint32 val = i->second.second;
4534 SettingsFlagsAndId flags_and_id(flags, id);
4535 settings.push_back(SpdySetting(flags_and_id, val));
4536 }
4537
4541 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); 4538 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings));
4542 4539
4543 // Construct the request. 4540 // Construct the request.
4544 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4541 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4545 4542
4546 MockWrite writes[] = { 4543 MockWrite writes[] = {
4547 CreateMockWrite(*settings_frame), 4544 CreateMockWrite(*settings_frame),
4548 CreateMockWrite(*req), 4545 CreateMockWrite(*req),
4549 }; 4546 };
4550 4547
(...skipping 18 matching lines...) Expand all
4569 helper.AddData(data.get()); 4566 helper.AddData(data.get());
4570 helper.RunDefaultTest(); 4567 helper.RunDefaultTest();
4571 helper.VerifyDataConsumed(); 4568 helper.VerifyDataConsumed();
4572 TransactionHelperResult out = helper.output(); 4569 TransactionHelperResult out = helper.output();
4573 EXPECT_EQ(OK, out.rv); 4570 EXPECT_EQ(OK, out.rv);
4574 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 4571 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
4575 EXPECT_EQ("hello!", out.response_data); 4572 EXPECT_EQ("hello!", out.response_data);
4576 4573
4577 { 4574 {
4578 // Verify we had two persisted settings. 4575 // Verify we had two persisted settings.
4579 SpdySettings saved_settings = 4576 const SettingsMap& settings_map =
4580 spdy_session_pool->http_server_properties()->GetSpdySettings( 4577 spdy_session_pool->http_server_properties()->GetSpdySettings(
4581 host_port_pair); 4578 host_port_pair);
4582 ASSERT_EQ(2u, saved_settings.size()); 4579 ASSERT_EQ(2u, settings_map.size());
4583 4580
4584 // Verify the first persisted setting. 4581 // Verify the first persisted setting.
4585 SpdySetting setting = saved_settings.front(); 4582 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1);
4586 saved_settings.pop_front(); 4583 EXPECT_TRUE(it1 != settings_map.end());
4587 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); 4584 SettingsFlagsAndValue flags_and_value1 = it1->second;
4588 EXPECT_EQ(kSampleId1, setting.first.id()); 4585 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first);
4589 EXPECT_EQ(kSampleValue1, setting.second); 4586 EXPECT_EQ(kSampleValue1, flags_and_value1.second);
4590 4587
4591 // Verify the second persisted setting. 4588 // Verify the second persisted setting.
4592 setting = saved_settings.front(); 4589 SettingsMap::const_iterator it2 = settings_map.find(kSampleId2);
4593 saved_settings.pop_front(); 4590 EXPECT_TRUE(it2 != settings_map.end());
4594 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); 4591 SettingsFlagsAndValue flags_and_value2 = it2->second;
4595 EXPECT_EQ(kSampleId2, setting.first.id()); 4592 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value2.first);
4596 EXPECT_EQ(kSampleValue2, setting.second); 4593 EXPECT_EQ(kSampleValue2, flags_and_value2.second);
4597 } 4594 }
4598 } 4595 }
4599 4596
4600 TEST_P(SpdyNetworkTransactionSpdy3Test, GoAwayWithActiveStream) { 4597 TEST_P(SpdyNetworkTransactionSpdy3Test, GoAwayWithActiveStream) {
4601 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4598 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4602 MockWrite writes[] = { CreateMockWrite(*req) }; 4599 MockWrite writes[] = { CreateMockWrite(*req) };
4603 4600
4604 scoped_ptr<SpdyFrame> go_away(ConstructSpdyGoAway()); 4601 scoped_ptr<SpdyFrame> go_away(ConstructSpdyGoAway());
4605 MockRead reads[] = { 4602 MockRead reads[] = {
4606 CreateMockRead(*go_away), 4603 CreateMockRead(*go_away),
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
5866 << " Write index: " 5863 << " Write index: "
5867 << data->write_index(); 5864 << data->write_index();
5868 5865
5869 // Verify the SYN_REPLY. 5866 // Verify the SYN_REPLY.
5870 HttpResponseInfo response = *trans->GetResponseInfo(); 5867 HttpResponseInfo response = *trans->GetResponseInfo();
5871 EXPECT_TRUE(response.headers != NULL); 5868 EXPECT_TRUE(response.headers != NULL);
5872 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5869 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5873 } 5870 }
5874 5871
5875 } // namespace net 5872 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_spdy2_unittest.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698