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