| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 MockRead(ASYNC, 0, 3) // EOF | 835 MockRead(ASYNC, 0, 3) // EOF |
| 813 }; | 836 }; |
| 814 | 837 |
| 815 SequencedSocketData data(reads, arraysize(reads), writes, | 838 SequencedSocketData data(reads, arraysize(reads), writes, |
| 816 arraysize(writes)); | 839 arraysize(writes)); |
| 817 HttpRequestInfo http_req = CreateGetRequest(); | 840 HttpRequestInfo http_req = CreateGetRequest(); |
| 818 | 841 |
| 819 NormalSpdyTransactionHelper helper(http_req, p, BoundNetLog(), | 842 NormalSpdyTransactionHelper helper(http_req, p, BoundNetLog(), |
| 820 GetParam(), NULL); | 843 GetParam(), NULL); |
| 821 helper.RunToCompletion(&data); | 844 helper.RunToCompletion(&data); |
| 845 spdy_util_.OnStreamDestruction(1); |
| 822 TransactionHelperResult out = helper.output(); | 846 TransactionHelperResult out = helper.output(); |
| 823 EXPECT_EQ(OK, out.rv); | 847 EXPECT_EQ(OK, out.rv); |
| 824 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 848 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 825 EXPECT_EQ("hello!", out.response_data); | 849 EXPECT_EQ("hello!", out.response_data); |
| 826 } | 850 } |
| 827 } | 851 } |
| 828 | 852 |
| 829 // Start three gets simultaniously; making sure that multiplexed | 853 // Start three gets simultaniously; making sure that multiplexed |
| 830 // streams work properly. | 854 // streams work properly. |
| 831 | 855 |
| (...skipping 283 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_.OnStreamDestruction(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_.OnStreamDestruction(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)); |
| 1169 spdy_util_.OnStreamDestruction(5); |
| 1142 | 1170 |
| 1143 SettingsMap settings; | 1171 SettingsMap settings; |
| 1144 const uint32 max_concurrent_streams = 1; | 1172 const uint32 max_concurrent_streams = 1; |
| 1145 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1173 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| 1146 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); | 1174 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); |
| 1147 scoped_ptr<SpdyFrame> settings_frame( | 1175 scoped_ptr<SpdyFrame> settings_frame( |
| 1148 spdy_util_.ConstructSpdySettings(settings)); | 1176 spdy_util_.ConstructSpdySettings(settings)); |
| 1149 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck()); | 1177 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck()); |
| 1150 | 1178 |
| 1151 MockWrite writes[] = { | 1179 MockWrite writes[] = { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 // different data ("hello!" vs "hello!hello!") and because of the | 1276 // different data ("hello!" vs "hello!hello!") and because of the |
| 1249 // user specified priority, we expect to see them inverted in | 1277 // user specified priority, we expect to see them inverted in |
| 1250 // the response from the server. | 1278 // the response from the server. |
| 1251 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { | 1279 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { |
| 1252 // Construct the request. | 1280 // Construct the request. |
| 1253 scoped_ptr<SpdyFrame> req( | 1281 scoped_ptr<SpdyFrame> req( |
| 1254 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1282 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1255 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1283 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1256 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1284 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1257 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1285 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1286 spdy_util_.OnStreamDestruction(1); |
| 1258 | 1287 |
| 1259 scoped_ptr<SpdyFrame> req2( | 1288 scoped_ptr<SpdyFrame> req2( |
| 1260 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1289 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1261 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1290 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1262 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 1291 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| 1263 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); | 1292 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); |
| 1293 // TODO(rdsmith): I'm concerned that the actual creation/destruction order, |
| 1294 // and hence the wire bytes, are racy here. |
| 1295 spdy_util_.OnStreamDestruction(3); |
| 1264 | 1296 |
| 1265 scoped_ptr<SpdyFrame> req4( | 1297 scoped_ptr<SpdyFrame> req4( |
| 1266 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, HIGHEST, true)); | 1298 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, HIGHEST, true)); |
| 1267 scoped_ptr<SpdyFrame> resp4(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5)); | 1299 scoped_ptr<SpdyFrame> resp4(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5)); |
| 1268 scoped_ptr<SpdyFrame> fbody4(spdy_util_.ConstructSpdyBodyFrame(5, true)); | 1300 scoped_ptr<SpdyFrame> fbody4(spdy_util_.ConstructSpdyBodyFrame(5, true)); |
| 1301 spdy_util_.OnStreamDestruction(5); |
| 1269 | 1302 |
| 1270 scoped_ptr<SpdyFrame> req3( | 1303 scoped_ptr<SpdyFrame> req3( |
| 1271 spdy_util_.ConstructSpdyGet(NULL, 0, false, 7, LOWEST, true)); | 1304 spdy_util_.ConstructSpdyGet(NULL, 0, false, 7, LOWEST, true)); |
| 1272 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 7)); | 1305 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 7)); |
| 1273 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(7, false)); | 1306 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(7, false)); |
| 1274 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(7, true)); | 1307 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(7, true)); |
| 1275 | 1308 |
| 1276 SettingsMap settings; | 1309 SettingsMap settings; |
| 1277 const uint32 max_concurrent_streams = 1; | 1310 const uint32 max_concurrent_streams = 1; |
| 1278 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1311 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 | 1430 // deletes a session in the middle of the transaction to ensure |
| 1398 // that we properly remove pendingcreatestream objects from | 1431 // that we properly remove pendingcreatestream objects from |
| 1399 // the spdy_session | 1432 // the spdy_session |
| 1400 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { | 1433 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { |
| 1401 // Construct the request. | 1434 // Construct the request. |
| 1402 scoped_ptr<SpdyFrame> req( | 1435 scoped_ptr<SpdyFrame> req( |
| 1403 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1436 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1404 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1437 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1405 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1438 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1406 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1439 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1440 spdy_util_.OnStreamDestruction(1); |
| 1407 | 1441 |
| 1408 scoped_ptr<SpdyFrame> req2( | 1442 scoped_ptr<SpdyFrame> req2( |
| 1409 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1443 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1410 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1444 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1411 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 1445 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| 1412 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); | 1446 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); |
| 1413 | 1447 |
| 1414 SettingsMap settings; | 1448 SettingsMap settings; |
| 1415 const uint32 max_concurrent_streams = 1; | 1449 const uint32 max_concurrent_streams = 1; |
| 1416 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1450 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 | 1562 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test |
| 1529 // closes the socket while we have a pending transaction waiting for | 1563 // closes the socket while we have a pending transaction waiting for |
| 1530 // a pending stream creation. http://crbug.com/52901 | 1564 // a pending stream creation. http://crbug.com/52901 |
| 1531 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { | 1565 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { |
| 1532 // Construct the request. | 1566 // Construct the request. |
| 1533 scoped_ptr<SpdyFrame> req( | 1567 scoped_ptr<SpdyFrame> req( |
| 1534 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1568 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1535 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1569 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1536 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1570 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1537 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1571 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1572 spdy_util_.OnStreamDestruction(1); |
| 1538 | 1573 |
| 1539 scoped_ptr<SpdyFrame> req2( | 1574 scoped_ptr<SpdyFrame> req2( |
| 1540 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1575 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1541 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1576 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1542 | 1577 |
| 1543 SettingsMap settings; | 1578 SettingsMap settings; |
| 1544 const uint32 max_concurrent_streams = 1; | 1579 const uint32 max_concurrent_streams = 1; |
| 1545 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 1580 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| 1546 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); | 1581 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); |
| 1547 scoped_ptr<SpdyFrame> settings_frame( | 1582 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) { | 3114 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 3080 scoped_ptr<SpdyFrame> req( | 3115 scoped_ptr<SpdyFrame> req( |
| 3081 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3116 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3082 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3117 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
| 3083 | 3118 |
| 3084 scoped_ptr<SpdyFrame> resp( | 3119 scoped_ptr<SpdyFrame> resp( |
| 3085 spdy_util_.ConstructSpdyGetSynReply(test_cases[i].extra_headers, | 3120 spdy_util_.ConstructSpdyGetSynReply(test_cases[i].extra_headers, |
| 3086 test_cases[i].num_headers, | 3121 test_cases[i].num_headers, |
| 3087 1)); | 3122 1)); |
| 3088 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3123 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3124 spdy_util_.OnStreamDestruction(1); |
| 3089 MockRead reads[] = { | 3125 MockRead reads[] = { |
| 3090 CreateMockRead(*resp, 1), | 3126 CreateMockRead(*resp, 1), |
| 3091 CreateMockRead(*body, 2), | 3127 CreateMockRead(*body, 2), |
| 3092 MockRead(ASYNC, 0, 3) // EOF | 3128 MockRead(ASYNC, 0, 3) // EOF |
| 3093 }; | 3129 }; |
| 3094 | 3130 |
| 3095 SequencedSocketData data(reads, arraysize(reads), writes, | 3131 SequencedSocketData data(reads, arraysize(reads), writes, |
| 3096 arraysize(writes)); | 3132 arraysize(writes)); |
| 3097 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3133 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3098 BoundNetLog(), GetParam(), NULL); | 3134 BoundNetLog(), GetParam(), NULL); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3176 | 3212 |
| 3177 // Construct the reply. | 3213 // Construct the reply. |
| 3178 SpdyHeaderBlock reply_headers; | 3214 SpdyHeaderBlock reply_headers; |
| 3179 AppendToHeaderBlock(test_cases[i].extra_headers[1], | 3215 AppendToHeaderBlock(test_cases[i].extra_headers[1], |
| 3180 test_cases[i].num_headers[1], | 3216 test_cases[i].num_headers[1], |
| 3181 &reply_headers); | 3217 &reply_headers); |
| 3182 scoped_ptr<SpdyFrame> frame_reply( | 3218 scoped_ptr<SpdyFrame> frame_reply( |
| 3183 spdy_util_.ConstructSpdyReply(1, reply_headers)); | 3219 spdy_util_.ConstructSpdyReply(1, reply_headers)); |
| 3184 | 3220 |
| 3185 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3221 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3222 spdy_util_.OnStreamDestruction(1); |
| 3186 MockRead reads[] = { | 3223 MockRead reads[] = { |
| 3187 CreateMockRead(*frame_reply, 1), | 3224 CreateMockRead(*frame_reply, 1), |
| 3188 CreateMockRead(*body, 2), | 3225 CreateMockRead(*body, 2), |
| 3189 MockRead(ASYNC, 0, 3) // EOF | 3226 MockRead(ASYNC, 0, 3) // EOF |
| 3190 }; | 3227 }; |
| 3191 | 3228 |
| 3192 // Attach the headers to the request. | 3229 // Attach the headers to the request. |
| 3193 int header_count = test_cases[i].num_headers[0]; | 3230 int header_count = test_cases[i].num_headers[0]; |
| 3194 | 3231 |
| 3195 HttpRequestInfo request = CreateGetRequest(); | 3232 HttpRequestInfo request = CreateGetRequest(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3271 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers)); | 3308 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers)); |
| 3272 MockRead reads[] = { | 3309 MockRead reads[] = { |
| 3273 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 3) // EOF | 3310 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 3) // EOF |
| 3274 }; | 3311 }; |
| 3275 | 3312 |
| 3276 SequencedSocketData data(reads, arraysize(reads), writes, | 3313 SequencedSocketData data(reads, arraysize(reads), writes, |
| 3277 arraysize(writes)); | 3314 arraysize(writes)); |
| 3278 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3315 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3279 BoundNetLog(), GetParam(), NULL); | 3316 BoundNetLog(), GetParam(), NULL); |
| 3280 helper.RunToCompletion(&data); | 3317 helper.RunToCompletion(&data); |
| 3318 spdy_util_.OnStreamDestruction(1); |
| 3281 TransactionHelperResult out = helper.output(); | 3319 TransactionHelperResult out = helper.output(); |
| 3282 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 3320 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 3283 } | 3321 } |
| 3284 } | 3322 } |
| 3285 | 3323 |
| 3286 // Verify that we don't crash on some corrupt frames. | 3324 // Verify that we don't crash on some corrupt frames. |
| 3287 // TODO(jgraettinger): HTTP/2 treats a header decompression failure as a | 3325 // TODO(jgraettinger): HTTP/2 treats a header decompression failure as a |
| 3288 // connection error. I'd like to backport this behavior to SPDY3 as well. | 3326 // connection error. I'd like to backport this behavior to SPDY3 as well. |
| 3289 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { | 3327 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { |
| 3290 if (spdy_util_.spdy_version() >= HTTP2) { | 3328 if (spdy_util_.spdy_version() >= HTTP2) { |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4640 HttpNetworkTransaction* trans = helper.trans(); | 4678 HttpNetworkTransaction* trans = helper.trans(); |
| 4641 | 4679 |
| 4642 TestCompletionCallback callback; | 4680 TestCompletionCallback callback; |
| 4643 TransactionHelperResult out; | 4681 TransactionHelperResult out; |
| 4644 out.rv = trans->Start( | 4682 out.rv = trans->Start( |
| 4645 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4683 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 4646 | 4684 |
| 4647 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 4685 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
| 4648 out.rv = callback.WaitForResult(); | 4686 out.rv = callback.WaitForResult(); |
| 4649 EXPECT_EQ(out.rv, OK); | 4687 EXPECT_EQ(out.rv, OK); |
| 4688 spdy_util_.OnStreamDestruction(1); |
| 4650 | 4689 |
| 4651 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4690 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4652 EXPECT_TRUE(response->headers.get() != NULL); | 4691 EXPECT_TRUE(response->headers.get() != NULL); |
| 4653 EXPECT_TRUE(response->was_fetched_via_spdy); | 4692 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4654 out.rv = ReadTransaction(trans, &out.response_data); | 4693 out.rv = ReadTransaction(trans, &out.response_data); |
| 4655 EXPECT_EQ(OK, out.rv); | 4694 EXPECT_EQ(OK, out.rv); |
| 4656 out.status_line = response->headers->GetStatusLine(); | 4695 out.status_line = response->headers->GetStatusLine(); |
| 4657 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4696 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 4658 EXPECT_EQ("hello!", out.response_data); | 4697 EXPECT_EQ("hello!", out.response_data); |
| 4659 | 4698 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4748 }; | 4787 }; |
| 4749 | 4788 |
| 4750 MockRead reads2[] = { | 4789 MockRead reads2[] = { |
| 4751 CreateMockRead(*resp, 1), | 4790 CreateMockRead(*resp, 1), |
| 4752 CreateMockRead(*body, 2), | 4791 CreateMockRead(*body, 2), |
| 4753 MockRead(ASYNC, 0, 3) // EOF | 4792 MockRead(ASYNC, 0, 3) // EOF |
| 4754 }; | 4793 }; |
| 4755 | 4794 |
| 4756 scoped_ptr<SpdyFrame> req( | 4795 scoped_ptr<SpdyFrame> req( |
| 4757 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4796 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4797 // In all cases the connection will be reset before req3 can be |
| 4798 // dispatched, destroying both streams. |
| 4799 spdy_util_.OnStreamDestruction(1); |
| 4758 scoped_ptr<SpdyFrame> req3( | 4800 scoped_ptr<SpdyFrame> req3( |
| 4759 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 4801 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 4760 MockWrite writes1[] = {CreateMockWrite(*req, 0), CreateMockWrite(*req3, 5)}; | 4802 MockWrite writes1[] = {CreateMockWrite(*req, 0), CreateMockWrite(*req3, 5)}; |
| 4761 MockWrite writes2[] = {CreateMockWrite(*req, 0)}; | 4803 MockWrite writes2[] = {CreateMockWrite(*req, 0)}; |
| 4804 spdy_util_.OnStreamDestruction(3); |
| 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. |
| 4768 // In this case, the send completed - everything copied into the SNDBUF. | 4811 // In this case, the send completed - everything copied into the SNDBUF. |
| 4769 VARIANT_RST_DURING_READ_COMPLETION = 1 | 4812 VARIANT_RST_DURING_READ_COMPLETION = 1 |
| 4770 }; | 4813 }; |
| 4771 | 4814 |
| (...skipping 103 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_.OnStreamDestruction(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_.OnStreamDestruction(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_.OnStreamDestruction(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 // TODO(rdsmith): Comment above does not match priorities below? |
| 5693 |
| 5694 // Ordering note: the test below will run in three phases: |
| 5695 // * Start req1, run -> seq 0 (i.e. all IO pending). |
| 5696 // * Start req2 & req3, run -> seq 2 (i.e. attempt write of req2 frame, |
| 5697 // return IO pending, run just allowing finish and close of req1). |
| 5698 // * Run -> seq 10 (allow all operations to complete). |
| 5699 // This will result in delaying the creation of the syn frame for |
| 5700 // req3 (happens on first write of req3, blocked by IO_PENDING for req2) |
| 5701 // until after req1 has finished. The OnStreamDestruction call below |
| 5702 // reflects this order. |
| 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_.OnStreamDestruction(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 |