| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // the TLS handshake. | 58 // the TLS handshake. |
| 59 HTTPS_SPDY_VIA_NPN, | 59 HTTPS_SPDY_VIA_NPN, |
| 60 // Request and http:// URL to a server that supports SPDY via Alternative | 60 // Request and http:// URL to a server that supports SPDY via Alternative |
| 61 // Service on port 443. | 61 // Service on port 443. |
| 62 // See: https//tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html | 62 // See: https//tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html |
| 63 HTTP_SPDY_VIA_ALT_SVC, | 63 HTTP_SPDY_VIA_ALT_SVC, |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 struct SpdyNetworkTransactionTestParams { | 66 struct SpdyNetworkTransactionTestParams { |
| 67 SpdyNetworkTransactionTestParams() | 67 SpdyNetworkTransactionTestParams() |
| 68 : protocol(kProtoSPDY31), ssl_type(HTTPS_SPDY_VIA_NPN) {} | 68 : protocol(kProtoSPDY31), |
| 69 ssl_type(HTTPS_SPDY_VIA_NPN), |
| 70 priority_to_dependency(false) {} |
| 69 | 71 |
| 70 SpdyNetworkTransactionTestParams(NextProto protocol, | 72 SpdyNetworkTransactionTestParams(NextProto protocol, |
| 71 SpdyNetworkTransactionTestSSLType ssl_type) | 73 SpdyNetworkTransactionTestSSLType ssl_type, |
| 72 : protocol(protocol), ssl_type(ssl_type) {} | 74 bool priority_to_dependency) |
| 75 : protocol(protocol), |
| 76 ssl_type(ssl_type), |
| 77 priority_to_dependency(priority_to_dependency) {} |
| 73 | 78 |
| 74 friend std::ostream& operator<<(std::ostream& os, | 79 friend std::ostream& operator<<(std::ostream& os, |
| 75 const SpdyNetworkTransactionTestParams& p) { | 80 const SpdyNetworkTransactionTestParams& p) { |
| 76 std::string type_str; | 81 std::string type_str; |
| 77 switch (p.ssl_type) { | 82 switch (p.ssl_type) { |
| 78 case HTTP_SPDY_VIA_ALT_SVC: | 83 case HTTP_SPDY_VIA_ALT_SVC: |
| 79 type_str = "HTTP_SPDY_VIA_ALT_SVC"; | 84 type_str = "HTTP_SPDY_VIA_ALT_SVC"; |
| 80 break; | 85 break; |
| 81 case HTTPS_SPDY_VIA_NPN: | 86 case HTTPS_SPDY_VIA_NPN: |
| 82 type_str = "HTTPS_SPDY_VIA_NPN"; | 87 type_str = "HTTPS_SPDY_VIA_NPN"; |
| 83 break; | 88 break; |
| 84 } | 89 } |
| 85 os << "{ protocol: " << SSLClientSocket::NextProtoToString(p.protocol) | 90 os << "{ protocol: " << SSLClientSocket::NextProtoToString(p.protocol) |
| 86 << ", ssl_type: " << type_str << " }"; | 91 << ", ssl_type: " << type_str |
| 92 << ", priority_to_dependency: " << p.priority_to_dependency << " }"; |
| 87 return os; | 93 return os; |
| 88 } | 94 } |
| 89 | 95 |
| 90 NextProto protocol; | 96 NextProto protocol; |
| 91 SpdyNetworkTransactionTestSSLType ssl_type; | 97 SpdyNetworkTransactionTestSSLType ssl_type; |
| 98 bool priority_to_dependency; |
| 92 }; | 99 }; |
| 93 | 100 |
| 94 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params, | 101 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params, |
| 95 SpdySessionDependencies* session_deps) { | 102 SpdySessionDependencies* session_deps) { |
| 96 session_deps->use_alternative_services = true; | 103 session_deps->use_alternative_services = true; |
| 97 session_deps->next_protos = SpdyNextProtos(); | 104 session_deps->next_protos = SpdyNextProtos(); |
| 98 if (test_params.ssl_type == HTTP_SPDY_VIA_ALT_SVC) { | 105 if (test_params.ssl_type == HTTP_SPDY_VIA_ALT_SVC) { |
| 99 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 106 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 100 session_deps->http_server_properties.SetAlternativeService( | 107 session_deps->http_server_properties.SetAlternativeService( |
| 101 HostPortPair("www.example.org", 80), | 108 HostPortPair("www.example.org", 80), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 120 new SpdySessionDependencies(test_params.protocol, proxy_service.Pass())); | 127 new SpdySessionDependencies(test_params.protocol, proxy_service.Pass())); |
| 121 UpdateSpdySessionDependencies(test_params, session_deps.get()); | 128 UpdateSpdySessionDependencies(test_params, session_deps.get()); |
| 122 return session_deps; | 129 return session_deps; |
| 123 } | 130 } |
| 124 | 131 |
| 125 } // namespace | 132 } // namespace |
| 126 | 133 |
| 127 class SpdyNetworkTransactionTest | 134 class SpdyNetworkTransactionTest |
| 128 : public ::testing::TestWithParam<SpdyNetworkTransactionTestParams> { | 135 : public ::testing::TestWithParam<SpdyNetworkTransactionTestParams> { |
| 129 protected: | 136 protected: |
| 130 SpdyNetworkTransactionTest() : spdy_util_(GetParam().protocol) { | 137 SpdyNetworkTransactionTest() |
| 138 : spdy_util_(GetParam().protocol, GetParam().priority_to_dependency) { |
| 139 SpdySession::SetPriorityDependencyDefaultForTesting( |
| 140 GetParam().priority_to_dependency); |
| 131 spdy_util_.set_default_url(GURL(GetDefaultUrl())); | 141 spdy_util_.set_default_url(GURL(GetDefaultUrl())); |
| 132 } | 142 } |
| 133 | 143 |
| 134 virtual ~SpdyNetworkTransactionTest() { | 144 virtual ~SpdyNetworkTransactionTest() { |
| 135 // UploadDataStream may post a deletion tasks back to the message loop on | 145 // UploadDataStream may post a deletion tasks back to the message loop on |
| 136 // destruction. | 146 // destruction. |
| 137 upload_data_stream_.reset(); | 147 upload_data_stream_.reset(); |
| 138 base::RunLoop().RunUntilIdle(); | 148 base::RunLoop().RunUntilIdle(); |
| 149 SpdySession::SetPriorityDependencyDefaultForTesting(false); |
| 139 } | 150 } |
| 140 | 151 |
| 141 void SetUp() override { | 152 void SetUp() override { |
| 142 get_request_initialized_ = false; | 153 get_request_initialized_ = false; |
| 143 post_request_initialized_ = false; | 154 post_request_initialized_ = false; |
| 144 chunked_post_request_initialized_ = false; | 155 chunked_post_request_initialized_ = false; |
| 145 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 156 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 146 } | 157 } |
| 147 | 158 |
| 148 struct TransactionHelperResult { | 159 struct TransactionHelperResult { |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 //----------------------------------------------------------------------------- | 716 //----------------------------------------------------------------------------- |
| 706 // All tests are run with three different connection types: SPDY after NPN | 717 // All tests are run with three different connection types: SPDY after NPN |
| 707 // negotiation, SPDY without SSL, and SPDY with SSL. | 718 // negotiation, SPDY without SSL, and SPDY with SSL. |
| 708 // | 719 // |
| 709 // TODO(akalin): Use ::testing::Combine() when we are able to use | 720 // TODO(akalin): Use ::testing::Combine() when we are able to use |
| 710 // <tr1/tuple>. | 721 // <tr1/tuple>. |
| 711 INSTANTIATE_TEST_CASE_P( | 722 INSTANTIATE_TEST_CASE_P( |
| 712 Spdy, | 723 Spdy, |
| 713 SpdyNetworkTransactionTest, | 724 SpdyNetworkTransactionTest, |
| 714 ::testing::Values( | 725 ::testing::Values( |
| 715 SpdyNetworkTransactionTestParams(kProtoSPDY31, HTTPS_SPDY_VIA_NPN), | 726 SpdyNetworkTransactionTestParams(kProtoSPDY31, |
| 716 SpdyNetworkTransactionTestParams(kProtoSPDY31, HTTP_SPDY_VIA_ALT_SVC), | 727 HTTPS_SPDY_VIA_NPN, |
| 717 SpdyNetworkTransactionTestParams(kProtoHTTP2, HTTPS_SPDY_VIA_NPN), | 728 false), |
| 718 SpdyNetworkTransactionTestParams(kProtoHTTP2, HTTP_SPDY_VIA_ALT_SVC))); | 729 SpdyNetworkTransactionTestParams(kProtoSPDY31, |
| 730 HTTP_SPDY_VIA_ALT_SVC, |
| 731 false), |
| 732 SpdyNetworkTransactionTestParams(kProtoHTTP2, |
| 733 HTTPS_SPDY_VIA_NPN, |
| 734 false), |
| 735 SpdyNetworkTransactionTestParams(kProtoHTTP2, HTTPS_SPDY_VIA_NPN, true), |
| 736 SpdyNetworkTransactionTestParams(kProtoHTTP2, |
| 737 HTTP_SPDY_VIA_ALT_SVC, |
| 738 false), |
| 739 SpdyNetworkTransactionTestParams(kProtoHTTP2, |
| 740 HTTP_SPDY_VIA_ALT_SVC, |
| 741 true))); |
| 719 | 742 |
| 720 // Verify HttpNetworkTransaction constructor. | 743 // Verify HttpNetworkTransaction constructor. |
| 721 TEST_P(SpdyNetworkTransactionTest, Constructor) { | 744 TEST_P(SpdyNetworkTransactionTest, Constructor) { |
| 722 scoped_ptr<SpdySessionDependencies> session_deps( | 745 scoped_ptr<SpdySessionDependencies> session_deps( |
| 723 CreateSpdySessionDependencies(GetParam())); | 746 CreateSpdySessionDependencies(GetParam())); |
| 724 scoped_ptr<HttpNetworkSession> session( | 747 scoped_ptr<HttpNetworkSession> session( |
| 725 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); | 748 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); |
| 726 scoped_ptr<HttpTransaction> trans( | 749 scoped_ptr<HttpTransaction> trans( |
| 727 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 750 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 728 } | 751 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 750 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 773 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 751 EXPECT_EQ("hello!", out.response_data); | 774 EXPECT_EQ("hello!", out.response_data); |
| 752 } | 775 } |
| 753 | 776 |
| 754 TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { | 777 TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { |
| 755 for (RequestPriority p = MINIMUM_PRIORITY; p <= MAXIMUM_PRIORITY; | 778 for (RequestPriority p = MINIMUM_PRIORITY; p <= MAXIMUM_PRIORITY; |
| 756 p = RequestPriority(p + 1)) { | 779 p = RequestPriority(p + 1)) { |
| 757 // Construct the request. | 780 // Construct the request. |
| 758 scoped_ptr<SpdyFrame> req( | 781 scoped_ptr<SpdyFrame> req( |
| 759 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, p, true)); | 782 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, p, true)); |
| 783 spdy_util_.UpdateWithStreamDestruction(1); |
| 760 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 784 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
| 761 | 785 |
| 762 SpdyPriority spdy_prio = 0; | 786 SpdyPriority spdy_prio = 0; |
| 763 EXPECT_TRUE(GetSpdyPriority(spdy_util_.spdy_version(), *req, &spdy_prio)); | 787 EXPECT_TRUE(GetSpdyPriority(spdy_util_.spdy_version(), *req, &spdy_prio)); |
| 764 // this repeats the RequestPriority-->SpdyPriority mapping from | 788 // this repeats the RequestPriority-->SpdyPriority mapping from |
| 765 // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make | 789 // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make |
| 766 // sure it's being done right. | 790 // sure it's being done right. |
| 767 if (spdy_util_.spdy_version() < SPDY3) { | 791 if (spdy_util_.spdy_version() < SPDY3) { |
| 768 switch (p) { | 792 switch (p) { |
| 769 case HIGHEST: | 793 case HIGHEST: |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 helper.VerifyDataConsumed(); | 1139 helper.VerifyDataConsumed(); |
| 1116 } | 1140 } |
| 1117 | 1141 |
| 1118 // Similar to ThreeGets above, however this test adds a SETTINGS | 1142 // Similar to ThreeGets above, however this test adds a SETTINGS |
| 1119 // frame. The SETTINGS frame is read during the IO loop waiting on | 1143 // frame. The SETTINGS frame is read during the IO loop waiting on |
| 1120 // the first transaction completion, and sets a maximum concurrent | 1144 // the first transaction completion, and sets a maximum concurrent |
| 1121 // stream limit of 1. This means that our IO loop exists after the | 1145 // stream limit of 1. This means that our IO loop exists after the |
| 1122 // second transaction completes, so we can assert on read_index(). | 1146 // second transaction completes, so we can assert on read_index(). |
| 1123 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { | 1147 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { |
| 1124 // Construct the request. | 1148 // Construct the request. |
| 1149 // Each request fully completes before the next starts. |
| 1125 scoped_ptr<SpdyFrame> req( | 1150 scoped_ptr<SpdyFrame> req( |
| 1126 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1151 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1127 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1152 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1128 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1153 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1129 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1154 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1155 spdy_util_.UpdateWithStreamDestruction(1); |
| 1130 | 1156 |
| 1131 scoped_ptr<SpdyFrame> req2( | 1157 scoped_ptr<SpdyFrame> req2( |
| 1132 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1158 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1133 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1159 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1134 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 1160 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| 1135 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); | 1161 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); |
| 1162 spdy_util_.UpdateWithStreamDestruction(3); |
| 1136 | 1163 |
| 1137 scoped_ptr<SpdyFrame> req3( | 1164 scoped_ptr<SpdyFrame> req3( |
| 1138 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, LOWEST, true)); | 1165 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, LOWEST, true)); |
| 1139 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5)); | 1166 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5)); |
| 1140 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(5, false)); | 1167 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(5, false)); |
| 1141 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(5, true)); | 1168 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(5, true)); |
| 1142 | 1169 |
| 1143 SettingsMap settings; | 1170 SettingsMap settings; |
| 1144 const uint32 max_concurrent_streams = 1; | 1171 const uint32 max_concurrent_streams = 1; |
| 1145 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1172 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 // different data ("hello!" vs "hello!hello!") and because of the | 1275 // different data ("hello!" vs "hello!hello!") and because of the |
| 1249 // user specified priority, we expect to see them inverted in | 1276 // user specified priority, we expect to see them inverted in |
| 1250 // the response from the server. | 1277 // the response from the server. |
| 1251 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { | 1278 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { |
| 1252 // Construct the request. | 1279 // Construct the request. |
| 1253 scoped_ptr<SpdyFrame> req( | 1280 scoped_ptr<SpdyFrame> req( |
| 1254 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1281 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1255 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1282 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1256 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1283 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1257 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1284 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1285 spdy_util_.UpdateWithStreamDestruction(1); |
| 1258 | 1286 |
| 1259 scoped_ptr<SpdyFrame> req2( | 1287 scoped_ptr<SpdyFrame> req2( |
| 1260 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1288 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1261 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1289 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1262 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 1290 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| 1263 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); | 1291 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); |
| 1292 spdy_util_.UpdateWithStreamDestruction(3); |
| 1264 | 1293 |
| 1265 scoped_ptr<SpdyFrame> req4( | 1294 scoped_ptr<SpdyFrame> req4( |
| 1266 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, HIGHEST, true)); | 1295 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, HIGHEST, true)); |
| 1267 scoped_ptr<SpdyFrame> resp4(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5)); | 1296 scoped_ptr<SpdyFrame> resp4(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5)); |
| 1268 scoped_ptr<SpdyFrame> fbody4(spdy_util_.ConstructSpdyBodyFrame(5, true)); | 1297 scoped_ptr<SpdyFrame> fbody4(spdy_util_.ConstructSpdyBodyFrame(5, true)); |
| 1298 spdy_util_.UpdateWithStreamDestruction(5); |
| 1269 | 1299 |
| 1270 scoped_ptr<SpdyFrame> req3( | 1300 scoped_ptr<SpdyFrame> req3( |
| 1271 spdy_util_.ConstructSpdyGet(NULL, 0, false, 7, LOWEST, true)); | 1301 spdy_util_.ConstructSpdyGet(NULL, 0, false, 7, LOWEST, true)); |
| 1272 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 7)); | 1302 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 7)); |
| 1273 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(7, false)); | 1303 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(7, false)); |
| 1274 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(7, true)); | 1304 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(7, true)); |
| 1275 | 1305 |
| 1276 SettingsMap settings; | 1306 SettingsMap settings; |
| 1277 const uint32 max_concurrent_streams = 1; | 1307 const uint32 max_concurrent_streams = 1; |
| 1278 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1308 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 // deletes a session in the middle of the transaction to ensure | 1427 // deletes a session in the middle of the transaction to ensure |
| 1398 // that we properly remove pendingcreatestream objects from | 1428 // that we properly remove pendingcreatestream objects from |
| 1399 // the spdy_session | 1429 // the spdy_session |
| 1400 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { | 1430 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { |
| 1401 // Construct the request. | 1431 // Construct the request. |
| 1402 scoped_ptr<SpdyFrame> req( | 1432 scoped_ptr<SpdyFrame> req( |
| 1403 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1433 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1404 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1434 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1405 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1435 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1406 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1436 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1437 spdy_util_.UpdateWithStreamDestruction(1); |
| 1407 | 1438 |
| 1408 scoped_ptr<SpdyFrame> req2( | 1439 scoped_ptr<SpdyFrame> req2( |
| 1409 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1440 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1410 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1441 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1411 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 1442 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| 1412 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); | 1443 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); |
| 1413 | 1444 |
| 1414 SettingsMap settings; | 1445 SettingsMap settings; |
| 1415 const uint32 max_concurrent_streams = 1; | 1446 const uint32 max_concurrent_streams = 1; |
| 1416 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1447 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test | 1559 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test |
| 1529 // closes the socket while we have a pending transaction waiting for | 1560 // closes the socket while we have a pending transaction waiting for |
| 1530 // a pending stream creation. http://crbug.com/52901 | 1561 // a pending stream creation. http://crbug.com/52901 |
| 1531 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { | 1562 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { |
| 1532 // Construct the request. | 1563 // Construct the request. |
| 1533 scoped_ptr<SpdyFrame> req( | 1564 scoped_ptr<SpdyFrame> req( |
| 1534 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1565 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1535 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1566 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1536 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1567 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1537 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1568 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1569 spdy_util_.UpdateWithStreamDestruction(1); |
| 1538 | 1570 |
| 1539 scoped_ptr<SpdyFrame> req2( | 1571 scoped_ptr<SpdyFrame> req2( |
| 1540 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1572 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1541 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1573 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1542 | 1574 |
| 1543 SettingsMap settings; | 1575 SettingsMap settings; |
| 1544 const uint32 max_concurrent_streams = 1; | 1576 const uint32 max_concurrent_streams = 1; |
| 1545 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1577 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| 1546 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); | 1578 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); |
| 1547 scoped_ptr<SpdyFrame> settings_frame( | 1579 scoped_ptr<SpdyFrame> settings_frame( |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 3111 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 3080 scoped_ptr<SpdyFrame> req( | 3112 scoped_ptr<SpdyFrame> req( |
| 3081 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3113 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3082 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3114 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
| 3083 | 3115 |
| 3084 scoped_ptr<SpdyFrame> resp( | 3116 scoped_ptr<SpdyFrame> resp( |
| 3085 spdy_util_.ConstructSpdyGetSynReply(test_cases[i].extra_headers, | 3117 spdy_util_.ConstructSpdyGetSynReply(test_cases[i].extra_headers, |
| 3086 test_cases[i].num_headers, | 3118 test_cases[i].num_headers, |
| 3087 1)); | 3119 1)); |
| 3088 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3120 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3121 spdy_util_.UpdateWithStreamDestruction(1); |
| 3089 MockRead reads[] = { | 3122 MockRead reads[] = { |
| 3090 CreateMockRead(*resp, 1), | 3123 CreateMockRead(*resp, 1), |
| 3091 CreateMockRead(*body, 2), | 3124 CreateMockRead(*body, 2), |
| 3092 MockRead(ASYNC, 0, 3) // EOF | 3125 MockRead(ASYNC, 0, 3) // EOF |
| 3093 }; | 3126 }; |
| 3094 | 3127 |
| 3095 SequencedSocketData data(reads, arraysize(reads), writes, | 3128 SequencedSocketData data(reads, arraysize(reads), writes, |
| 3096 arraysize(writes)); | 3129 arraysize(writes)); |
| 3097 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3130 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3098 BoundNetLog(), GetParam(), NULL); | 3131 BoundNetLog(), GetParam(), NULL); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3176 | 3209 |
| 3177 // Construct the reply. | 3210 // Construct the reply. |
| 3178 SpdyHeaderBlock reply_headers; | 3211 SpdyHeaderBlock reply_headers; |
| 3179 AppendToHeaderBlock(test_cases[i].extra_headers[1], | 3212 AppendToHeaderBlock(test_cases[i].extra_headers[1], |
| 3180 test_cases[i].num_headers[1], | 3213 test_cases[i].num_headers[1], |
| 3181 &reply_headers); | 3214 &reply_headers); |
| 3182 scoped_ptr<SpdyFrame> frame_reply( | 3215 scoped_ptr<SpdyFrame> frame_reply( |
| 3183 spdy_util_.ConstructSpdyReply(1, reply_headers)); | 3216 spdy_util_.ConstructSpdyReply(1, reply_headers)); |
| 3184 | 3217 |
| 3185 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3218 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3219 spdy_util_.UpdateWithStreamDestruction(1); |
| 3186 MockRead reads[] = { | 3220 MockRead reads[] = { |
| 3187 CreateMockRead(*frame_reply, 1), | 3221 CreateMockRead(*frame_reply, 1), |
| 3188 CreateMockRead(*body, 2), | 3222 CreateMockRead(*body, 2), |
| 3189 MockRead(ASYNC, 0, 3) // EOF | 3223 MockRead(ASYNC, 0, 3) // EOF |
| 3190 }; | 3224 }; |
| 3191 | 3225 |
| 3192 // Attach the headers to the request. | 3226 // Attach the headers to the request. |
| 3193 int header_count = test_cases[i].num_headers[0]; | 3227 int header_count = test_cases[i].num_headers[0]; |
| 3194 | 3228 |
| 3195 HttpRequestInfo request = CreateGetRequest(); | 3229 HttpRequestInfo request = CreateGetRequest(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3253 { | 3287 { |
| 3254 0, {NULL}, | 3288 0, {NULL}, |
| 3255 }, | 3289 }, |
| 3256 }; | 3290 }; |
| 3257 | 3291 |
| 3258 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 3292 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 3259 scoped_ptr<SpdyFrame> req( | 3293 scoped_ptr<SpdyFrame> req( |
| 3260 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3294 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3261 scoped_ptr<SpdyFrame> rst( | 3295 scoped_ptr<SpdyFrame> rst( |
| 3262 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 3296 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 3297 spdy_util_.UpdateWithStreamDestruction(1); |
| 3263 MockWrite writes[] = { | 3298 MockWrite writes[] = { |
| 3264 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2), | 3299 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2), |
| 3265 }; | 3300 }; |
| 3266 | 3301 |
| 3267 // Construct the reply. | 3302 // Construct the reply. |
| 3268 SpdyHeaderBlock reply_headers; | 3303 SpdyHeaderBlock reply_headers; |
| 3269 AppendToHeaderBlock( | 3304 AppendToHeaderBlock( |
| 3270 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); | 3305 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); |
| 3271 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers)); | 3306 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers)); |
| 3272 MockRead reads[] = { | 3307 MockRead reads[] = { |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4661 HostPortPair host_port_pair("www.example.org", helper.port()); | 4696 HostPortPair host_port_pair("www.example.org", helper.port()); |
| 4662 SpdySessionKey session_pool_key_direct( | 4697 SpdySessionKey session_pool_key_direct( |
| 4663 host_port_pair, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); | 4698 host_port_pair, ProxyServer::Direct(), PRIVACY_MODE_DISABLED); |
| 4664 EXPECT_TRUE(HasSpdySession(spdy_session_pool, session_pool_key_direct)); | 4699 EXPECT_TRUE(HasSpdySession(spdy_session_pool, session_pool_key_direct)); |
| 4665 SpdySessionKey session_pool_key_proxy( | 4700 SpdySessionKey session_pool_key_proxy( |
| 4666 host_port_pair, | 4701 host_port_pair, |
| 4667 ProxyServer::FromURI("www.foo.com", ProxyServer::SCHEME_HTTP), | 4702 ProxyServer::FromURI("www.foo.com", ProxyServer::SCHEME_HTTP), |
| 4668 PRIVACY_MODE_DISABLED); | 4703 PRIVACY_MODE_DISABLED); |
| 4669 EXPECT_FALSE(HasSpdySession(spdy_session_pool, session_pool_key_proxy)); | 4704 EXPECT_FALSE(HasSpdySession(spdy_session_pool, session_pool_key_proxy)); |
| 4670 | 4705 |
| 4706 // New SpdyTestUtil instance for the session that will be used for the |
| 4707 // proxy connection. |
| 4708 SpdyTestUtil spdy_util_2(GetParam().protocol, |
| 4709 GetParam().priority_to_dependency); |
| 4710 |
| 4671 // Set up data for the proxy connection. | 4711 // Set up data for the proxy connection. |
| 4672 const char kConnect443[] = { | 4712 const char kConnect443[] = { |
| 4673 "CONNECT www.example.org:443 HTTP/1.1\r\n" | 4713 "CONNECT www.example.org:443 HTTP/1.1\r\n" |
| 4674 "Host: www.example.org\r\n" | 4714 "Host: www.example.org\r\n" |
| 4675 "Proxy-Connection: keep-alive\r\n\r\n"}; | 4715 "Proxy-Connection: keep-alive\r\n\r\n"}; |
| 4676 const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"}; | 4716 const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"}; |
| 4677 scoped_ptr<SpdyFrame> req2(spdy_util_.ConstructSpdyGet( | 4717 scoped_ptr<SpdyFrame> req2(spdy_util_2.ConstructSpdyGet( |
| 4678 GetDefaultUrlWithPath("/foo.dat").c_str(), false, 1, LOWEST)); | 4718 GetDefaultUrlWithPath("/foo.dat").c_str(), false, 1, LOWEST)); |
| 4679 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4719 scoped_ptr<SpdyFrame> resp2(spdy_util_2.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 4680 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4720 scoped_ptr<SpdyFrame> body2(spdy_util_2.ConstructSpdyBodyFrame(1, true)); |
| 4681 | 4721 |
| 4682 MockWrite writes2[] = { | 4722 MockWrite writes2[] = { |
| 4683 MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0), | 4723 MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0), |
| 4684 CreateMockWrite(*req2, 2), | 4724 CreateMockWrite(*req2, 2), |
| 4685 }; | 4725 }; |
| 4686 MockRead reads2[] = { | 4726 MockRead reads2[] = { |
| 4687 MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1), | 4727 MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1), |
| 4688 CreateMockRead(*resp2, 3), | 4728 CreateMockRead(*resp2, 3), |
| 4689 CreateMockRead(*body2, 4), | 4729 CreateMockRead(*body2, 4), |
| 4690 MockRead(ASYNC, 0, 5) // EOF | 4730 MockRead(ASYNC, 0, 5) // EOF |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4748 }; | 4788 }; |
| 4749 | 4789 |
| 4750 MockRead reads2[] = { | 4790 MockRead reads2[] = { |
| 4751 CreateMockRead(*resp, 1), | 4791 CreateMockRead(*resp, 1), |
| 4752 CreateMockRead(*body, 2), | 4792 CreateMockRead(*body, 2), |
| 4753 MockRead(ASYNC, 0, 3) // EOF | 4793 MockRead(ASYNC, 0, 3) // EOF |
| 4754 }; | 4794 }; |
| 4755 | 4795 |
| 4756 scoped_ptr<SpdyFrame> req( | 4796 scoped_ptr<SpdyFrame> req( |
| 4757 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4797 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4798 // In all cases the connection will be reset before req3 can be |
| 4799 // dispatched, destroying both streams. |
| 4800 spdy_util_.UpdateWithStreamDestruction(1); |
| 4758 scoped_ptr<SpdyFrame> req3( | 4801 scoped_ptr<SpdyFrame> req3( |
| 4759 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 4802 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 4760 MockWrite writes1[] = {CreateMockWrite(*req, 0), CreateMockWrite(*req3, 5)}; | 4803 MockWrite writes1[] = {CreateMockWrite(*req, 0), CreateMockWrite(*req3, 5)}; |
| 4761 MockWrite writes2[] = {CreateMockWrite(*req, 0)}; | 4804 MockWrite writes2[] = {CreateMockWrite(*req, 0)}; |
| 4762 | 4805 |
| 4763 // This test has a couple of variants. | 4806 // This test has a couple of variants. |
| 4764 enum { | 4807 enum { |
| 4765 // Induce the RST while waiting for our transaction to send. | 4808 // Induce the RST while waiting for our transaction to send. |
| 4766 VARIANT_RST_DURING_SEND_COMPLETION = 0, | 4809 VARIANT_RST_DURING_SEND_COMPLETION = 0, |
| 4767 // Induce the RST while waiting for our transaction to read. | 4810 // Induce the RST while waiting for our transaction to read. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4875 } | 4918 } |
| 4876 | 4919 |
| 4877 // Tests that Basic authentication works over SPDY | 4920 // Tests that Basic authentication works over SPDY |
| 4878 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { | 4921 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { |
| 4879 HttpStreamFactory::set_spdy_enabled(true); | 4922 HttpStreamFactory::set_spdy_enabled(true); |
| 4880 | 4923 |
| 4881 // The first request will be a bare GET, the second request will be a | 4924 // The first request will be a bare GET, the second request will be a |
| 4882 // GET with an Authorization header. | 4925 // GET with an Authorization header. |
| 4883 scoped_ptr<SpdyFrame> req_get( | 4926 scoped_ptr<SpdyFrame> req_get( |
| 4884 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4927 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4928 // Will be refused for lack of auth. |
| 4929 spdy_util_.UpdateWithStreamDestruction(1); |
| 4885 const char* const kExtraAuthorizationHeaders[] = { | 4930 const char* const kExtraAuthorizationHeaders[] = { |
| 4886 "authorization", "Basic Zm9vOmJhcg==" | 4931 "authorization", "Basic Zm9vOmJhcg==" |
| 4887 }; | 4932 }; |
| 4888 scoped_ptr<SpdyFrame> req_get_authorization( | 4933 scoped_ptr<SpdyFrame> req_get_authorization( |
| 4889 spdy_util_.ConstructSpdyGet(kExtraAuthorizationHeaders, | 4934 spdy_util_.ConstructSpdyGet(kExtraAuthorizationHeaders, |
| 4890 arraysize(kExtraAuthorizationHeaders) / 2, | 4935 arraysize(kExtraAuthorizationHeaders) / 2, |
| 4891 false, 3, LOWEST, true)); | 4936 false, 3, LOWEST, true)); |
| 4892 MockWrite spdy_writes[] = { | 4937 MockWrite spdy_writes[] = { |
| 4893 CreateMockWrite(*req_get, 0), CreateMockWrite(*req_get_authorization, 3), | 4938 CreateMockWrite(*req_get, 0), CreateMockWrite(*req_get_authorization, 3), |
| 4894 }; | 4939 }; |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5503 }; | 5548 }; |
| 5504 | 5549 |
| 5505 for (size_t index = 0; index < arraysize(kTestCases); index += 2) { | 5550 for (size_t index = 0; index < arraysize(kTestCases); index += 2) { |
| 5506 const char* url_to_fetch = kTestCases[index]; | 5551 const char* url_to_fetch = kTestCases[index]; |
| 5507 const char* url_to_push = kTestCases[index + 1]; | 5552 const char* url_to_push = kTestCases[index + 1]; |
| 5508 | 5553 |
| 5509 scoped_ptr<SpdyFrame> stream1_syn( | 5554 scoped_ptr<SpdyFrame> stream1_syn( |
| 5510 spdy_util_.ConstructSpdyGet(url_to_fetch, false, 1, LOWEST)); | 5555 spdy_util_.ConstructSpdyGet(url_to_fetch, false, 1, LOWEST)); |
| 5511 scoped_ptr<SpdyFrame> stream1_body( | 5556 scoped_ptr<SpdyFrame> stream1_body( |
| 5512 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5557 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5558 spdy_util_.UpdateWithStreamDestruction(1); |
| 5513 scoped_ptr<SpdyFrame> push_rst( | 5559 scoped_ptr<SpdyFrame> push_rst( |
| 5514 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 5560 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
| 5515 MockWrite writes[] = { | 5561 MockWrite writes[] = { |
| 5516 CreateMockWrite(*stream1_syn, 0), CreateMockWrite(*push_rst, 3), | 5562 CreateMockWrite(*stream1_syn, 0), CreateMockWrite(*push_rst, 3), |
| 5517 }; | 5563 }; |
| 5518 | 5564 |
| 5519 scoped_ptr<SpdyFrame> | 5565 scoped_ptr<SpdyFrame> |
| 5520 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5566 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5521 scoped_ptr<SpdyFrame> | 5567 scoped_ptr<SpdyFrame> |
| 5522 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 5568 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5584 // Verify the SYN_REPLY. | 5630 // Verify the SYN_REPLY. |
| 5585 EXPECT_TRUE(response.headers.get() != NULL); | 5631 EXPECT_TRUE(response.headers.get() != NULL); |
| 5586 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5632 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5587 } | 5633 } |
| 5588 } | 5634 } |
| 5589 | 5635 |
| 5590 TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) { | 5636 TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) { |
| 5591 // Construct the request. | 5637 // Construct the request. |
| 5592 scoped_ptr<SpdyFrame> req( | 5638 scoped_ptr<SpdyFrame> req( |
| 5593 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5639 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5640 // Will be destroyed by the RST before stream 3 starts. |
| 5641 spdy_util_.UpdateWithStreamDestruction(1); |
| 5594 scoped_ptr<SpdyFrame> req2( | 5642 scoped_ptr<SpdyFrame> req2( |
| 5595 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 5643 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 5596 MockWrite writes[] = { | 5644 MockWrite writes[] = { |
| 5597 CreateMockWrite(*req, 0), CreateMockWrite(*req2, 2), | 5645 CreateMockWrite(*req, 0), CreateMockWrite(*req2, 2), |
| 5598 }; | 5646 }; |
| 5599 | 5647 |
| 5600 scoped_ptr<SpdyFrame> refused( | 5648 scoped_ptr<SpdyFrame> refused( |
| 5601 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_REFUSED_STREAM)); | 5649 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_REFUSED_STREAM)); |
| 5602 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 5650 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 5603 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(3, true)); | 5651 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(3, true)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5634 EXPECT_TRUE(response.headers.get() != NULL); | 5682 EXPECT_TRUE(response.headers.get() != NULL); |
| 5635 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5683 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5636 } | 5684 } |
| 5637 | 5685 |
| 5638 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { | 5686 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { |
| 5639 // This first request will start to establish the SpdySession. | 5687 // This first request will start to establish the SpdySession. |
| 5640 // Then we will start the second (MEDIUM priority) and then third | 5688 // Then we will start the second (MEDIUM priority) and then third |
| 5641 // (HIGHEST priority) request in such a way that the third will actually | 5689 // (HIGHEST priority) request in such a way that the third will actually |
| 5642 // start before the second, causing the second to be numbered differently | 5690 // start before the second, causing the second to be numbered differently |
| 5643 // than the order they were created. | 5691 // than the order they were created. |
| 5692 // |
| 5693 // Note that the requests and responses created below are expectations |
| 5694 // of what the above will produce on the wire, and hence are in the |
| 5695 // initial->HIGHEST->LOWEST priority. |
| 5696 // |
| 5697 // Frames are created by SpdySession just before the write associated |
| 5698 // with the frame is attempted, so stream dependencies will be based |
| 5699 // on the streams alive at the point of the request write attempt. Thus |
| 5700 // req1 is alive when req2 is attempted (during but not after the |
| 5701 // |data.RunFor(2);| statement below) but not when req3 is attempted. |
| 5702 // The call to spdy_util_.UpdateWithStreamDestruction() reflects this. |
| 5644 scoped_ptr<SpdyFrame> req1( | 5703 scoped_ptr<SpdyFrame> req1( |
| 5645 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5704 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5646 scoped_ptr<SpdyFrame> req2( | 5705 scoped_ptr<SpdyFrame> req2( |
| 5647 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, HIGHEST, true)); | 5706 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, HIGHEST, true)); |
| 5707 spdy_util_.UpdateWithStreamDestruction(1); |
| 5648 scoped_ptr<SpdyFrame> req3( | 5708 scoped_ptr<SpdyFrame> req3( |
| 5649 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, MEDIUM, true)); | 5709 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, MEDIUM, true)); |
| 5650 MockWrite writes[] = { | 5710 MockWrite writes[] = { |
| 5651 CreateMockWrite(*req1, 0), | 5711 CreateMockWrite(*req1, 0), |
| 5652 CreateMockWrite(*req2, 3), | 5712 CreateMockWrite(*req2, 3), |
| 5653 CreateMockWrite(*req3, 4), | 5713 CreateMockWrite(*req3, 4), |
| 5654 }; | 5714 }; |
| 5655 | 5715 |
| 5656 scoped_ptr<SpdyFrame> resp1(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5716 scoped_ptr<SpdyFrame> resp1(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5657 scoped_ptr<SpdyFrame> body1(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5717 scoped_ptr<SpdyFrame> body1(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6525 //----------------------------------------------------------------------------- | 6585 //----------------------------------------------------------------------------- |
| 6526 // All tests are run with three different connection types: SPDY after NPN | 6586 // All tests are run with three different connection types: SPDY after NPN |
| 6527 // negotiation, SPDY without SSL, and SPDY with SSL. | 6587 // negotiation, SPDY without SSL, and SPDY with SSL. |
| 6528 // | 6588 // |
| 6529 // TODO(akalin): Use ::testing::Combine() when we are able to use | 6589 // TODO(akalin): Use ::testing::Combine() when we are able to use |
| 6530 // <tr1/tuple>. | 6590 // <tr1/tuple>. |
| 6531 INSTANTIATE_TEST_CASE_P( | 6591 INSTANTIATE_TEST_CASE_P( |
| 6532 Spdy, | 6592 Spdy, |
| 6533 SpdyNetworkTransactionNoTLSUsageCheckTest, | 6593 SpdyNetworkTransactionNoTLSUsageCheckTest, |
| 6534 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoSPDY31, | 6594 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoSPDY31, |
| 6535 HTTPS_SPDY_VIA_NPN))); | 6595 HTTPS_SPDY_VIA_NPN, |
| 6596 false))); |
| 6536 | 6597 |
| 6537 TEST_P(SpdyNetworkTransactionNoTLSUsageCheckTest, TLSVersionTooOld) { | 6598 TEST_P(SpdyNetworkTransactionNoTLSUsageCheckTest, TLSVersionTooOld) { |
| 6538 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6599 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
| 6539 new SSLSocketDataProvider(ASYNC, OK)); | 6600 new SSLSocketDataProvider(ASYNC, OK)); |
| 6540 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, | 6601 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, |
| 6541 &ssl_provider->connection_status); | 6602 &ssl_provider->connection_status); |
| 6542 | 6603 |
| 6543 RunNoTLSUsageCheckTest(ssl_provider.Pass()); | 6604 RunNoTLSUsageCheckTest(ssl_provider.Pass()); |
| 6544 } | 6605 } |
| 6545 | 6606 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6568 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 6629 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
| 6569 helper.RunToCompletionWithSSLData(&data, ssl_provider.Pass()); | 6630 helper.RunToCompletionWithSSLData(&data, ssl_provider.Pass()); |
| 6570 TransactionHelperResult out = helper.output(); | 6631 TransactionHelperResult out = helper.output(); |
| 6571 EXPECT_EQ(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY, out.rv); | 6632 EXPECT_EQ(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY, out.rv); |
| 6572 } | 6633 } |
| 6573 }; | 6634 }; |
| 6574 | 6635 |
| 6575 INSTANTIATE_TEST_CASE_P( | 6636 INSTANTIATE_TEST_CASE_P( |
| 6576 Spdy, | 6637 Spdy, |
| 6577 SpdyNetworkTransactionTLSUsageCheckTest, | 6638 SpdyNetworkTransactionTLSUsageCheckTest, |
| 6578 ::testing::Values( | 6639 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoHTTP2, |
| 6579 SpdyNetworkTransactionTestParams(kProtoHTTP2, HTTPS_SPDY_VIA_NPN))); | 6640 HTTPS_SPDY_VIA_NPN, |
| 6641 false), |
| 6642 SpdyNetworkTransactionTestParams(kProtoHTTP2, |
| 6643 HTTPS_SPDY_VIA_NPN, |
| 6644 true))); |
| 6580 | 6645 |
| 6581 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { | 6646 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { |
| 6582 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6647 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
| 6583 new SSLSocketDataProvider(ASYNC, OK)); | 6648 new SSLSocketDataProvider(ASYNC, OK)); |
| 6584 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, | 6649 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, |
| 6585 &ssl_provider->connection_status); | 6650 &ssl_provider->connection_status); |
| 6586 | 6651 |
| 6587 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6652 RunTLSUsageCheckTest(ssl_provider.Pass()); |
| 6588 } | 6653 } |
| 6589 | 6654 |
| 6590 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6655 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 6591 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6656 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
| 6592 new SSLSocketDataProvider(ASYNC, OK)); | 6657 new SSLSocketDataProvider(ASYNC, OK)); |
| 6593 // Set to TLS_RSA_WITH_NULL_MD5 | 6658 // Set to TLS_RSA_WITH_NULL_MD5 |
| 6594 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6659 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 6595 | 6660 |
| 6596 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6661 RunTLSUsageCheckTest(ssl_provider.Pass()); |
| 6597 } | 6662 } |
| 6598 | 6663 |
| 6599 } // namespace net | 6664 } // namespace net |
| OLD | NEW |