| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 // Construct the request. | 1342 // Construct the request. |
| 1346 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1343 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 1347 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1344 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1348 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 1345 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
| 1349 scoped_ptr<SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); | 1346 scoped_ptr<SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); |
| 1350 | 1347 |
| 1351 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 1348 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
| 1352 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 1349 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1353 | 1350 |
| 1354 SpdySettings settings; | 1351 SpdySettings settings; |
| 1355 SettingsFlagsAndId id(0, SETTINGS_MAX_CONCURRENT_STREAMS); | 1352 SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); |
| 1356 const size_t max_concurrent_streams = 1; | 1353 const size_t max_concurrent_streams = 1; |
| 1357 | 1354 |
| 1358 settings.push_back(SpdySetting(id, max_concurrent_streams)); | 1355 settings.push_back(SpdySetting(id, max_concurrent_streams)); |
| 1359 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); | 1356 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); |
| 1360 | 1357 |
| 1361 MockWrite writes[] = { CreateMockWrite(*req), | 1358 MockWrite writes[] = { CreateMockWrite(*req), |
| 1362 CreateMockWrite(*req2), | 1359 CreateMockWrite(*req2), |
| 1363 }; | 1360 }; |
| 1364 MockRead reads[] = { | 1361 MockRead reads[] = { |
| 1365 CreateMockRead(*settings_frame, 1), | 1362 CreateMockRead(*settings_frame, 1), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1393 TestCompletionCallback callback1; | 1390 TestCompletionCallback callback1; |
| 1394 TestCompletionCallback callback2; | 1391 TestCompletionCallback callback2; |
| 1395 KillerCallback callback3(trans3); | 1392 KillerCallback callback3(trans3); |
| 1396 | 1393 |
| 1397 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1394 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 1398 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1395 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 1399 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1396 HttpRequestInfo httpreq3 = CreateGetRequest(); |
| 1400 | 1397 |
| 1401 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); | 1398 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); |
| 1402 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1399 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1403 // run transaction 1 through quickly to force a read of our SETTINGS | 1400 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
| 1404 // frame | |
| 1405 out.rv = callback1.WaitForResult(); | 1401 out.rv = callback1.WaitForResult(); |
| 1406 ASSERT_EQ(OK, out.rv); | 1402 ASSERT_EQ(OK, out.rv); |
| 1407 | 1403 |
| 1408 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); | 1404 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); |
| 1409 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1405 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1410 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1406 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
| 1411 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1407 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1412 out.rv = callback3.WaitForResult(); | 1408 out.rv = callback3.WaitForResult(); |
| 1413 ASSERT_EQ(ERR_ABORTED, out.rv); | 1409 ASSERT_EQ(ERR_ABORTED, out.rv); |
| 1414 | 1410 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1435 | 1431 |
| 1436 // Test that a simple PUT request works. | 1432 // Test that a simple PUT request works. |
| 1437 TEST_P(SpdyNetworkTransactionSpdy2Test, Put) { | 1433 TEST_P(SpdyNetworkTransactionSpdy2Test, Put) { |
| 1438 // Setup the request | 1434 // Setup the request |
| 1439 HttpRequestInfo request; | 1435 HttpRequestInfo request; |
| 1440 request.method = "PUT"; | 1436 request.method = "PUT"; |
| 1441 request.url = GURL("http://www.google.com/"); | 1437 request.url = GURL("http://www.google.com/"); |
| 1442 | 1438 |
| 1443 const SpdyHeaderInfo kSynStartHeader = { | 1439 const SpdyHeaderInfo kSynStartHeader = { |
| 1444 SYN_STREAM, // Kind = Syn | 1440 SYN_STREAM, // Kind = Syn |
| 1445 1, // Stream ID | 1441 1, // Stream ID |
| 1446 0, // Associated stream ID | 1442 0, // Associated stream ID |
| 1447 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 1443 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 1448 CONTROL_FLAG_FIN, // Control Flags | 1444 CONTROL_FLAG_FIN, // Control Flags |
| 1449 false, // Compressed | 1445 false, // Compressed |
| 1450 INVALID, // Status | 1446 INVALID, // Status |
| 1451 NULL, // Data | 1447 NULL, // Data |
| 1452 0, // Length | 1448 0, // Length |
| 1453 DATA_FLAG_NONE // Data Flags | 1449 DATA_FLAG_NONE // Data Flags |
| 1454 }; | 1450 }; |
| 1455 const char* const kPutHeaders[] = { | 1451 const char* const kPutHeaders[] = { |
| 1456 "method", "PUT", | 1452 "method", "PUT", |
| 1457 "url", "/", | 1453 "url", "/", |
| 1458 "host", "www.google.com", | 1454 "host", "www.google.com", |
| 1459 "scheme", "http", | 1455 "scheme", "http", |
| 1460 "version", "HTTP/1.1", | 1456 "version", "HTTP/1.1", |
| 1461 "content-length", "0" | 1457 "content-length", "0" |
| 1462 }; | 1458 }; |
| 1463 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, | 1459 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, |
| 1464 kPutHeaders, arraysize(kPutHeaders) / 2)); | 1460 kPutHeaders, arraysize(kPutHeaders) / 2)); |
| 1465 MockWrite writes[] = { | 1461 MockWrite writes[] = { |
| 1466 CreateMockWrite(*req) | 1462 CreateMockWrite(*req) |
| 1467 }; | 1463 }; |
| 1468 | 1464 |
| 1469 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1465 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1470 const SpdyHeaderInfo kSynReplyHeader = { | 1466 const SpdyHeaderInfo kSynReplyHeader = { |
| 1471 SYN_REPLY, // Kind = SynReply | 1467 SYN_REPLY, // Kind = SynReply |
| 1472 1, // Stream ID | 1468 1, // Stream ID |
| 1473 0, // Associated stream ID | 1469 0, // Associated stream ID |
| 1474 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 1470 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 1475 CONTROL_FLAG_NONE, // Control Flags | 1471 CONTROL_FLAG_NONE, // Control Flags |
| 1476 false, // Compressed | 1472 false, // Compressed |
| 1477 INVALID, // Status | 1473 INVALID, // Status |
| 1478 NULL, // Data | 1474 NULL, // Data |
| 1479 0, // Length | 1475 0, // Length |
| 1480 DATA_FLAG_NONE // Data Flags | 1476 DATA_FLAG_NONE // Data Flags |
| 1481 }; | 1477 }; |
| 1482 static const char* const kStandardGetHeaders[] = { | 1478 static const char* const kStandardGetHeaders[] = { |
| 1483 "status", "200", | 1479 "status", "200", |
| 1484 "version", "HTTP/1.1" | 1480 "version", "HTTP/1.1" |
| 1485 "content-length", "1234" | 1481 "content-length", "1234" |
| 1486 }; | 1482 }; |
| 1487 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, | 1483 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, |
| 1488 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); | 1484 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); |
| 1489 MockRead reads[] = { | 1485 MockRead reads[] = { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1506 | 1502 |
| 1507 // Test that a simple HEAD request works. | 1503 // Test that a simple HEAD request works. |
| 1508 TEST_P(SpdyNetworkTransactionSpdy2Test, Head) { | 1504 TEST_P(SpdyNetworkTransactionSpdy2Test, Head) { |
| 1509 // Setup the request | 1505 // Setup the request |
| 1510 HttpRequestInfo request; | 1506 HttpRequestInfo request; |
| 1511 request.method = "HEAD"; | 1507 request.method = "HEAD"; |
| 1512 request.url = GURL("http://www.google.com/"); | 1508 request.url = GURL("http://www.google.com/"); |
| 1513 | 1509 |
| 1514 const SpdyHeaderInfo kSynStartHeader = { | 1510 const SpdyHeaderInfo kSynStartHeader = { |
| 1515 SYN_STREAM, // Kind = Syn | 1511 SYN_STREAM, // Kind = Syn |
| 1516 1, // Stream ID | 1512 1, // Stream ID |
| 1517 0, // Associated stream ID | 1513 0, // Associated stream ID |
| 1518 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 1514 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 1519 CONTROL_FLAG_FIN, // Control Flags | 1515 CONTROL_FLAG_FIN, // Control Flags |
| 1520 false, // Compressed | 1516 false, // Compressed |
| 1521 INVALID, // Status | 1517 INVALID, // Status |
| 1522 NULL, // Data | 1518 NULL, // Data |
| 1523 0, // Length | 1519 0, // Length |
| 1524 DATA_FLAG_NONE // Data Flags | 1520 DATA_FLAG_NONE // Data Flags |
| 1525 }; | 1521 }; |
| 1526 const char* const kHeadHeaders[] = { | 1522 const char* const kHeadHeaders[] = { |
| 1527 "method", "HEAD", | 1523 "method", "HEAD", |
| 1528 "url", "/", | 1524 "url", "/", |
| 1529 "host", "www.google.com", | 1525 "host", "www.google.com", |
| 1530 "scheme", "http", | 1526 "scheme", "http", |
| 1531 "version", "HTTP/1.1", | 1527 "version", "HTTP/1.1", |
| 1532 "content-length", "0" | 1528 "content-length", "0" |
| 1533 }; | 1529 }; |
| 1534 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, | 1530 scoped_ptr<SpdyFrame> req(ConstructSpdyPacket(kSynStartHeader, NULL, 0, |
| 1535 kHeadHeaders, arraysize(kHeadHeaders) / 2)); | 1531 kHeadHeaders, arraysize(kHeadHeaders) / 2)); |
| 1536 MockWrite writes[] = { | 1532 MockWrite writes[] = { |
| 1537 CreateMockWrite(*req) | 1533 CreateMockWrite(*req) |
| 1538 }; | 1534 }; |
| 1539 | 1535 |
| 1540 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1536 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 1541 const SpdyHeaderInfo kSynReplyHeader = { | 1537 const SpdyHeaderInfo kSynReplyHeader = { |
| 1542 SYN_REPLY, // Kind = SynReply | 1538 SYN_REPLY, // Kind = SynReply |
| 1543 1, // Stream ID | 1539 1, // Stream ID |
| 1544 0, // Associated stream ID | 1540 0, // Associated stream ID |
| 1545 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 1541 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 1546 CONTROL_FLAG_NONE, // Control Flags | 1542 CONTROL_FLAG_NONE, // Control Flags |
| 1547 false, // Compressed | 1543 false, // Compressed |
| 1548 INVALID, // Status | 1544 INVALID, // Status |
| 1549 NULL, // Data | 1545 NULL, // Data |
| 1550 0, // Length | 1546 0, // Length |
| 1551 DATA_FLAG_NONE // Data Flags | 1547 DATA_FLAG_NONE // Data Flags |
| 1552 }; | 1548 }; |
| 1553 static const char* const kStandardGetHeaders[] = { | 1549 static const char* const kStandardGetHeaders[] = { |
| 1554 "status", "200", | 1550 "status", "200", |
| 1555 "version", "HTTP/1.1" | 1551 "version", "HTTP/1.1" |
| 1556 "content-length", "1234" | 1552 "content-length", "1234" |
| 1557 }; | 1553 }; |
| 1558 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, | 1554 scoped_ptr<SpdyFrame> resp(ConstructSpdyPacket(kSynReplyHeader, |
| 1559 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); | 1555 NULL, 0, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); |
| 1560 MockRead reads[] = { | 1556 MockRead reads[] = { |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3104 } | 3100 } |
| 3105 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines); | 3101 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines); |
| 3106 } | 3102 } |
| 3107 } | 3103 } |
| 3108 | 3104 |
| 3109 // Verify that various SynReply headers parse vary fields correctly | 3105 // Verify that various SynReply headers parse vary fields correctly |
| 3110 // through the HTTP layer, and the response matches the request. | 3106 // through the HTTP layer, and the response matches the request. |
| 3111 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyHeadersVary) { | 3107 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyHeadersVary) { |
| 3112 static const SpdyHeaderInfo syn_reply_info = { | 3108 static const SpdyHeaderInfo syn_reply_info = { |
| 3113 SYN_REPLY, // Syn Reply | 3109 SYN_REPLY, // Syn Reply |
| 3114 1, // Stream ID | 3110 1, // Stream ID |
| 3115 0, // Associated Stream ID | 3111 0, // Associated Stream ID |
| 3116 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 3112 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 3117 // Priority | |
| 3118 CONTROL_FLAG_NONE, // Control Flags | 3113 CONTROL_FLAG_NONE, // Control Flags |
| 3119 false, // Compressed | 3114 false, // Compressed |
| 3120 INVALID, // Status | 3115 INVALID, // Status |
| 3121 NULL, // Data | 3116 NULL, // Data |
| 3122 0, // Data Length | 3117 0, // Data Length |
| 3123 DATA_FLAG_NONE // Data Flags | 3118 DATA_FLAG_NONE // Data Flags |
| 3124 }; | 3119 }; |
| 3125 // Modify the following data to change/add test cases: | 3120 // Modify the following data to change/add test cases: |
| 3126 struct SynReplyTests { | 3121 struct SynReplyTests { |
| 3127 const SpdyHeaderInfo* syn_reply; | 3122 const SpdyHeaderInfo* syn_reply; |
| 3128 bool vary_matches; | 3123 bool vary_matches; |
| 3129 int num_headers[2]; | 3124 int num_headers[2]; |
| 3130 const char* extra_headers[2][16]; | 3125 const char* extra_headers[2][16]; |
| 3131 } test_cases[] = { | 3126 } test_cases[] = { |
| 3132 // Test the case of a multi-valued cookie. When the value is delimited | 3127 // 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... |
| 3273 256); | 3268 256); |
| 3274 | 3269 |
| 3275 EXPECT_EQ(std::string(reply_buffer), lines) << i; | 3270 EXPECT_EQ(std::string(reply_buffer), lines) << i; |
| 3276 } | 3271 } |
| 3277 } | 3272 } |
| 3278 | 3273 |
| 3279 // Verify that we don't crash on invalid SynReply responses. | 3274 // Verify that we don't crash on invalid SynReply responses. |
| 3280 TEST_P(SpdyNetworkTransactionSpdy2Test, InvalidSynReply) { | 3275 TEST_P(SpdyNetworkTransactionSpdy2Test, InvalidSynReply) { |
| 3281 const SpdyHeaderInfo kSynStartHeader = { | 3276 const SpdyHeaderInfo kSynStartHeader = { |
| 3282 SYN_REPLY, // Kind = SynReply | 3277 SYN_REPLY, // Kind = SynReply |
| 3283 1, // Stream ID | 3278 1, // Stream ID |
| 3284 0, // Associated stream ID | 3279 0, // Associated stream ID |
| 3285 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 3280 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 3286 // Priority | |
| 3287 CONTROL_FLAG_NONE, // Control Flags | 3281 CONTROL_FLAG_NONE, // Control Flags |
| 3288 false, // Compressed | 3282 false, // Compressed |
| 3289 INVALID, // Status | 3283 INVALID, // Status |
| 3290 NULL, // Data | 3284 NULL, // Data |
| 3291 0, // Length | 3285 0, // Length |
| 3292 DATA_FLAG_NONE // Data Flags | 3286 DATA_FLAG_NONE // Data Flags |
| 3293 }; | 3287 }; |
| 3294 | 3288 |
| 3295 struct InvalidSynReplyTests { | 3289 struct InvalidSynReplyTests { |
| 3296 int num_headers; | 3290 int num_headers; |
| 3297 const char* headers[10]; | 3291 const char* headers[10]; |
| 3298 } test_cases[] = { | 3292 } test_cases[] = { |
| 3299 // SYN_REPLY missing status header | 3293 // SYN_REPLY missing status header |
| 3300 { 4, | 3294 { 4, |
| 3301 { "cookie", "val1", | 3295 { "cookie", "val1", |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3994 | 3988 |
| 3995 // Verify that we consumed all test data. | 3989 // Verify that we consumed all test data. |
| 3996 helper.VerifyDataConsumed(); | 3990 helper.VerifyDataConsumed(); |
| 3997 } | 3991 } |
| 3998 | 3992 |
| 3999 // Test that if the server requests persistence of settings, that we save | 3993 // Test that if the server requests persistence of settings, that we save |
| 4000 // the settings in the SpdySettingsStorage. | 3994 // the settings in the SpdySettingsStorage. |
| 4001 TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsSaved) { | 3995 TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsSaved) { |
| 4002 static const SpdyHeaderInfo kSynReplyInfo = { | 3996 static const SpdyHeaderInfo kSynReplyInfo = { |
| 4003 SYN_REPLY, // Syn Reply | 3997 SYN_REPLY, // Syn Reply |
| 4004 1, // Stream ID | 3998 1, // Stream ID |
| 4005 0, // Associated Stream ID | 3999 0, // Associated Stream ID |
| 4006 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 4000 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 4007 // Priority | |
| 4008 CONTROL_FLAG_NONE, // Control Flags | 4001 CONTROL_FLAG_NONE, // Control Flags |
| 4009 false, // Compressed | 4002 false, // Compressed |
| 4010 INVALID, // Status | 4003 INVALID, // Status |
| 4011 NULL, // Data | 4004 NULL, // Data |
| 4012 0, // Data Length | 4005 0, // Data Length |
| 4013 DATA_FLAG_NONE // Data Flags | 4006 DATA_FLAG_NONE // Data Flags |
| 4014 }; | 4007 }; |
| 4015 static const char* const kExtraHeaders[] = { | 4008 static const char* const kExtraHeaders[] = { |
| 4016 "status", "200", | 4009 "status", "200", |
| 4017 "version", "HTTP/1.1" | 4010 "version", "HTTP/1.1" |
| 4018 }; | 4011 }; |
| 4019 | 4012 |
| 4020 BoundNetLog net_log; | 4013 BoundNetLog net_log; |
| 4021 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); | 4014 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); |
| 4022 helper.RunPreTestSetup(); | 4015 helper.RunPreTestSetup(); |
| 4023 | 4016 |
| 4024 // Verify that no settings exist initially. | 4017 // Verify that no settings exist initially. |
| 4025 HostPortPair host_port_pair("www.google.com", helper.port()); | 4018 HostPortPair host_port_pair("www.google.com", helper.port()); |
| 4026 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4019 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4027 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4020 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4028 host_port_pair).empty()); | 4021 host_port_pair).empty()); |
| 4029 | 4022 |
| 4030 // Construct the request. | 4023 // Construct the request. |
| 4031 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4024 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 4032 MockWrite writes[] = { CreateMockWrite(*req) }; | 4025 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4033 | 4026 |
| 4034 // Construct the reply. | 4027 // Construct the reply. |
| 4035 scoped_ptr<SpdyFrame> reply( | 4028 scoped_ptr<SpdyFrame> reply( |
| 4036 ConstructSpdyPacket(kSynReplyInfo, | 4029 ConstructSpdyPacket(kSynReplyInfo, |
| 4037 kExtraHeaders, | 4030 kExtraHeaders, |
| 4038 arraysize(kExtraHeaders) / 2, | 4031 arraysize(kExtraHeaders) / 2, |
| 4039 NULL, | 4032 NULL, |
| 4040 0)); | 4033 0)); |
| 4041 | 4034 |
| 4042 unsigned int kSampleId1 = 0x1; | 4035 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH; |
| 4043 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4036 unsigned int kSampleValue1 = 0x0a0a0a0a; |
| 4044 unsigned int kSampleId2 = 0x2; | 4037 const SpdySettingsIds kSampleId2 = SETTINGS_DOWNLOAD_BANDWIDTH; |
| 4045 unsigned int kSampleValue2 = 0x0b0b0b0b; | 4038 unsigned int kSampleValue2 = 0x0b0b0b0b; |
| 4046 unsigned int kSampleId3 = 0x3; | 4039 const SpdySettingsIds kSampleId3 = SETTINGS_ROUND_TRIP_TIME; |
| 4047 unsigned int kSampleValue3 = 0x0c0c0c0c; | 4040 unsigned int kSampleValue3 = 0x0c0c0c0c; |
| 4048 scoped_ptr<SpdyFrame> settings_frame; | 4041 scoped_ptr<SpdyFrame> settings_frame; |
| 4049 { | 4042 { |
| 4050 // Construct the SETTINGS frame. | 4043 // Construct the SETTINGS frame. |
| 4051 SpdySettings settings; | 4044 SpdySettings settings; |
| 4052 // First add a persisted setting | 4045 // First add a persisted setting. |
| 4053 SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST, | 4046 SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId1); |
| 4054 kSampleId1); | |
| 4055 settings.push_back(std::make_pair(setting1, kSampleValue1)); | 4047 settings.push_back(std::make_pair(setting1, kSampleValue1)); |
| 4056 // Next add a non-persisted setting | 4048 // Next add a non-persisted setting. |
| 4057 SettingsFlagsAndId setting2(0, kSampleId2); | 4049 SettingsFlagsAndId setting2(SETTINGS_FLAG_NONE, kSampleId2); |
| 4058 settings.push_back(std::make_pair(setting2, kSampleValue2)); | 4050 settings.push_back(std::make_pair(setting2, kSampleValue2)); |
| 4059 // Next add another persisted setting | 4051 // Next add another persisted setting. |
| 4060 SettingsFlagsAndId setting3(SETTINGS_FLAG_PLEASE_PERSIST, | 4052 SettingsFlagsAndId setting3(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId3); |
| 4061 kSampleId3); | |
| 4062 settings.push_back(std::make_pair(setting3, kSampleValue3)); | 4053 settings.push_back(std::make_pair(setting3, kSampleValue3)); |
| 4063 settings_frame.reset(ConstructSpdySettings(settings)); | 4054 settings_frame.reset(ConstructSpdySettings(settings)); |
| 4064 } | 4055 } |
| 4065 | 4056 |
| 4066 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 4057 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| 4067 MockRead reads[] = { | 4058 MockRead reads[] = { |
| 4068 CreateMockRead(*reply), | 4059 CreateMockRead(*reply), |
| 4069 CreateMockRead(*body), | 4060 CreateMockRead(*body), |
| 4070 CreateMockRead(*settings_frame), | 4061 CreateMockRead(*settings_frame), |
| 4071 MockRead(ASYNC, 0, 0) // EOF | 4062 MockRead(ASYNC, 0, 0) // EOF |
| 4072 }; | 4063 }; |
| 4073 | 4064 |
| 4074 scoped_ptr<DelayedSocketData> data( | 4065 scoped_ptr<DelayedSocketData> data( |
| 4075 new DelayedSocketData(1, reads, arraysize(reads), | 4066 new DelayedSocketData(1, reads, arraysize(reads), |
| 4076 writes, arraysize(writes))); | 4067 writes, arraysize(writes))); |
| 4077 helper.AddData(data.get()); | 4068 helper.AddData(data.get()); |
| 4078 helper.RunDefaultTest(); | 4069 helper.RunDefaultTest(); |
| 4079 helper.VerifyDataConsumed(); | 4070 helper.VerifyDataConsumed(); |
| 4080 TransactionHelperResult out = helper.output(); | 4071 TransactionHelperResult out = helper.output(); |
| 4081 EXPECT_EQ(OK, out.rv); | 4072 EXPECT_EQ(OK, out.rv); |
| 4082 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4073 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 4083 EXPECT_EQ("hello!", out.response_data); | 4074 EXPECT_EQ("hello!", out.response_data); |
| 4084 | 4075 |
| 4085 // TODO(rtenneti): Persist spdy settings. | |
| 4086 #ifdef PERSIST_SPDY_SETTINGS | |
| 4087 { | 4076 { |
| 4088 // Verify we had two persisted settings. | 4077 // Verify we had two persisted settings. |
| 4089 SpdySettings saved_settings = | 4078 const SettingsMap& settings_map = |
| 4090 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4079 spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4091 host_port_pair); | 4080 host_port_pair); |
| 4092 ASSERT_EQ(2u, saved_settings.size()); | 4081 ASSERT_EQ(2u, settings_map.size()); |
| 4093 | 4082 |
| 4094 // Verify the first persisted setting. | 4083 // Verify the first persisted setting. |
| 4095 SpdySetting setting = saved_settings.front(); | 4084 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); |
| 4096 saved_settings.pop_front(); | 4085 EXPECT_TRUE(it1 != settings_map.end()); |
| 4097 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); | 4086 SettingsFlagsAndValue flags_and_value1 = it1->second; |
| 4098 EXPECT_EQ(kSampleId1, setting.first.id()); | 4087 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); |
| 4099 EXPECT_EQ(kSampleValue1, setting.second); | 4088 EXPECT_EQ(kSampleValue1, flags_and_value1.second); |
| 4100 | 4089 |
| 4101 // Verify the second persisted setting. | 4090 // Verify the second persisted setting. |
| 4102 setting = saved_settings.front(); | 4091 SettingsMap::const_iterator it3 = settings_map.find(kSampleId3); |
| 4103 saved_settings.pop_front(); | 4092 EXPECT_TRUE(it3 != settings_map.end()); |
| 4104 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); | 4093 SettingsFlagsAndValue flags_and_value3 = it3->second; |
| 4105 EXPECT_EQ(kSampleId3, setting.first.id()); | 4094 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); |
| 4106 EXPECT_EQ(kSampleValue3, setting.second); | 4095 EXPECT_EQ(kSampleValue3, flags_and_value3.second); |
| 4107 } | 4096 } |
| 4108 #endif | |
| 4109 } | 4097 } |
| 4110 | 4098 |
| 4111 // Test that when there are settings saved that they are sent back to the | 4099 // Test that when there are settings saved that they are sent back to the |
| 4112 // server upon session establishment. | 4100 // server upon session establishment. |
| 4113 TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsPlayback) { | 4101 TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsPlayback) { |
| 4114 static const SpdyHeaderInfo kSynReplyInfo = { | 4102 static const SpdyHeaderInfo kSynReplyInfo = { |
| 4115 SYN_REPLY, // Syn Reply | 4103 SYN_REPLY, // Syn Reply |
| 4116 1, // Stream ID | 4104 1, // Stream ID |
| 4117 0, // Associated Stream ID | 4105 0, // Associated Stream ID |
| 4118 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 4106 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
| 4119 // Priority | |
| 4120 CONTROL_FLAG_NONE, // Control Flags | 4107 CONTROL_FLAG_NONE, // Control Flags |
| 4121 false, // Compressed | 4108 false, // Compressed |
| 4122 INVALID, // Status | 4109 INVALID, // Status |
| 4123 NULL, // Data | 4110 NULL, // Data |
| 4124 0, // Data Length | 4111 0, // Data Length |
| 4125 DATA_FLAG_NONE // Data Flags | 4112 DATA_FLAG_NONE // Data Flags |
| 4126 }; | 4113 }; |
| 4127 static const char* kExtraHeaders[] = { | 4114 static const char* kExtraHeaders[] = { |
| 4128 "status", "200", | 4115 "status", "200", |
| 4129 "version", "HTTP/1.1" | 4116 "version", "HTTP/1.1" |
| 4130 }; | 4117 }; |
| 4131 | 4118 |
| 4132 BoundNetLog net_log; | 4119 BoundNetLog net_log; |
| 4133 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); | 4120 NormalSpdyTransactionHelper helper(CreateGetRequest(), net_log, GetParam()); |
| 4134 helper.RunPreTestSetup(); | 4121 helper.RunPreTestSetup(); |
| 4135 | 4122 |
| 4136 // Verify that no settings exist initially. | 4123 // Verify that no settings exist initially. |
| 4137 HostPortPair host_port_pair("www.google.com", helper.port()); | 4124 HostPortPair host_port_pair("www.google.com", helper.port()); |
| 4138 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4125 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4139 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4126 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4140 host_port_pair).empty()); | 4127 host_port_pair).empty()); |
| 4141 | 4128 |
| 4142 unsigned int kSampleId1 = 0x1; | 4129 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH; |
| 4143 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4130 unsigned int kSampleValue1 = 0x0a0a0a0a; |
| 4144 unsigned int kSampleId2 = 0xababab; | 4131 const SpdySettingsIds kSampleId2 = SETTINGS_ROUND_TRIP_TIME; |
| 4145 unsigned int kSampleValue2 = 0x0c0c0c0c; | 4132 unsigned int kSampleValue2 = 0x0c0c0c0c; |
| 4146 // Manually insert settings into the SpdySettingsStorage here. | |
| 4147 { | |
| 4148 SpdySettings settings; | |
| 4149 // First add a persisted setting | |
| 4150 SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST, | |
| 4151 kSampleId1); | |
| 4152 settings.push_back(std::make_pair(setting1, kSampleValue1)); | |
| 4153 // Next add another persisted setting | |
| 4154 SettingsFlagsAndId setting2(SETTINGS_FLAG_PLEASE_PERSIST, | |
| 4155 kSampleId2); | |
| 4156 settings.push_back(std::make_pair(setting2, kSampleValue2)); | |
| 4157 | 4133 |
| 4158 spdy_session_pool->http_server_properties()->SetSpdySettings( | 4134 // First add a persisted setting. |
| 4159 host_port_pair, settings); | 4135 spdy_session_pool->http_server_properties()->SetSpdySetting( |
| 4160 } | 4136 host_port_pair, |
| 4137 kSampleId1, |
| 4138 SETTINGS_FLAG_PLEASE_PERSIST, |
| 4139 kSampleValue1); |
| 4140 |
| 4141 // Next add another persisted setting. |
| 4142 spdy_session_pool->http_server_properties()->SetSpdySetting( |
| 4143 host_port_pair, |
| 4144 kSampleId2, |
| 4145 SETTINGS_FLAG_PLEASE_PERSIST, |
| 4146 kSampleValue2); |
| 4161 | 4147 |
| 4162 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( | 4148 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4163 host_port_pair).size()); | 4149 host_port_pair).size()); |
| 4164 | 4150 |
| 4165 // Construct the SETTINGS frame. | 4151 // Construct the SETTINGS frame. |
| 4166 const SpdySettings& settings = | 4152 const SettingsMap& settings_map = |
| 4167 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4153 spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4168 host_port_pair); | 4154 host_port_pair); |
| 4155 |
| 4156 SpdySettings settings; |
| 4157 for (SettingsMap::const_iterator i = settings_map.begin(), |
| 4158 end = settings_map.end(); i != end; ++i) { |
| 4159 const SpdySettingsIds id = i->first; |
| 4160 const SpdySettingsFlags flags = i->second.first; |
| 4161 const uint32 val = i->second.second; |
| 4162 SettingsFlagsAndId flags_and_id(flags, id); |
| 4163 settings.push_back(SpdySetting(flags_and_id, val)); |
| 4164 } |
| 4165 |
| 4169 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); | 4166 scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); |
| 4170 | 4167 |
| 4171 // Construct the request. | 4168 // Construct the request. |
| 4172 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4169 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 4173 | 4170 |
| 4174 MockWrite writes[] = { | 4171 MockWrite writes[] = { |
| 4175 CreateMockWrite(*settings_frame), | 4172 CreateMockWrite(*settings_frame), |
| 4176 CreateMockWrite(*req), | 4173 CreateMockWrite(*req), |
| 4177 }; | 4174 }; |
| 4178 | 4175 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4197 helper.AddData(data.get()); | 4194 helper.AddData(data.get()); |
| 4198 helper.RunDefaultTest(); | 4195 helper.RunDefaultTest(); |
| 4199 helper.VerifyDataConsumed(); | 4196 helper.VerifyDataConsumed(); |
| 4200 TransactionHelperResult out = helper.output(); | 4197 TransactionHelperResult out = helper.output(); |
| 4201 EXPECT_EQ(OK, out.rv); | 4198 EXPECT_EQ(OK, out.rv); |
| 4202 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4199 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 4203 EXPECT_EQ("hello!", out.response_data); | 4200 EXPECT_EQ("hello!", out.response_data); |
| 4204 | 4201 |
| 4205 { | 4202 { |
| 4206 // Verify we had two persisted settings. | 4203 // Verify we had two persisted settings. |
| 4207 SpdySettings saved_settings = | 4204 const SettingsMap& settings_map = |
| 4208 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4205 spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4209 host_port_pair); | 4206 host_port_pair); |
| 4210 ASSERT_EQ(2u, saved_settings.size()); | 4207 ASSERT_EQ(2u, settings_map.size()); |
| 4211 | 4208 |
| 4212 // Verify the first persisted setting. | 4209 // Verify the first persisted setting. |
| 4213 SpdySetting setting = saved_settings.front(); | 4210 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); |
| 4214 saved_settings.pop_front(); | 4211 EXPECT_TRUE(it1 != settings_map.end()); |
| 4215 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); | 4212 SettingsFlagsAndValue flags_and_value1 = it1->second; |
| 4216 EXPECT_EQ(kSampleId1, setting.first.id()); | 4213 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); |
| 4217 EXPECT_EQ(kSampleValue1, setting.second); | 4214 EXPECT_EQ(kSampleValue1, flags_and_value1.second); |
| 4218 | 4215 |
| 4219 // Verify the second persisted setting. | 4216 // Verify the second persisted setting. |
| 4220 setting = saved_settings.front(); | 4217 SettingsMap::const_iterator it2 = settings_map.find(kSampleId2); |
| 4221 saved_settings.pop_front(); | 4218 EXPECT_TRUE(it2 != settings_map.end()); |
| 4222 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, setting.first.flags()); | 4219 SettingsFlagsAndValue flags_and_value2 = it2->second; |
| 4223 EXPECT_EQ(kSampleId2, setting.first.id()); | 4220 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value2.first); |
| 4224 EXPECT_EQ(kSampleValue2, setting.second); | 4221 EXPECT_EQ(kSampleValue2, flags_and_value2.second); |
| 4225 } | 4222 } |
| 4226 } | 4223 } |
| 4227 | 4224 |
| 4228 TEST_P(SpdyNetworkTransactionSpdy2Test, GoAwayWithActiveStream) { | 4225 TEST_P(SpdyNetworkTransactionSpdy2Test, GoAwayWithActiveStream) { |
| 4229 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4226 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 4230 MockWrite writes[] = { CreateMockWrite(*req) }; | 4227 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4231 | 4228 |
| 4232 scoped_ptr<SpdyFrame> go_away(ConstructSpdyGoAway()); | 4229 scoped_ptr<SpdyFrame> go_away(ConstructSpdyGoAway()); |
| 4233 MockRead reads[] = { | 4230 MockRead reads[] = { |
| 4234 CreateMockRead(*go_away), | 4231 CreateMockRead(*go_away), |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5494 << " Write index: " | 5491 << " Write index: " |
| 5495 << data->write_index(); | 5492 << data->write_index(); |
| 5496 | 5493 |
| 5497 // Verify the SYN_REPLY. | 5494 // Verify the SYN_REPLY. |
| 5498 HttpResponseInfo response = *trans->GetResponseInfo(); | 5495 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 5499 EXPECT_TRUE(response.headers != NULL); | 5496 EXPECT_TRUE(response.headers != NULL); |
| 5500 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5497 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5501 } | 5498 } |
| 5502 | 5499 |
| 5503 } // namespace net | 5500 } // namespace net |
| OLD | NEW |