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

Side by Side Diff: net/quic/chromium/quic_network_transaction_unittest.cc

Issue 2964603002: JobController: do not create alternative job for those AlternativeServiceInfo (Closed)
Patch Set: Always initialize local variable to fix windows compile issue Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <ostream> 7 #include <ostream>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1183
1184 request_.url = GURL("https://" + origin.host()); 1184 request_.url = GURL("https://" + origin.host());
1185 AddQuicRemoteAlternativeServiceMapping( 1185 AddQuicRemoteAlternativeServiceMapping(
1186 MockCryptoClientStream::CONFIRM_HANDSHAKE, alternative); 1186 MockCryptoClientStream::CONFIRM_HANDSHAKE, alternative);
1187 AddHangingNonAlternateProtocolSocketData(); 1187 AddHangingNonAlternateProtocolSocketData();
1188 CreateSession(); 1188 CreateSession();
1189 1189
1190 SendRequestAndExpectQuicResponse("hello!"); 1190 SendRequestAndExpectQuicResponse("hello!");
1191 } 1191 }
1192 1192
1193 TEST_P(QuicNetworkTransactionTest, DoNotUseQuicForUnsupportedVersion) {
1194 QuicVersion unsupported_version = QUIC_VERSION_UNSUPPORTED;
1195 // Add support for another QUIC version besides |version_|. Also find a
1196 // unsupported version.
1197 for (const QuicVersion& version : AllSupportedVersions()) {
1198 if (version == version_)
1199 continue;
1200 if (supported_versions_.size() != 2) {
1201 supported_versions_.push_back(version);
1202 continue;
1203 }
1204 unsupported_version = version;
1205 break;
1206 }
1207 DCHECK_NE(unsupported_version, QUIC_VERSION_UNSUPPORTED);
1208
1209 // Set up alternative service to use QUIC with a version that is not
1210 // supported.
1211 url::SchemeHostPort server(request_.url);
1212 AlternativeService alternative_service(kProtoQUIC, kDefaultServerHostName,
1213 443);
1214 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
1215 http_server_properties_.SetQuicAlternativeService(
1216 server, alternative_service, expiration, {unsupported_version});
1217
1218 AlternativeServiceInfoVector alt_svc_info_vector =
1219 http_server_properties_.GetAlternativeServiceInfos(server);
1220 EXPECT_EQ(1u, alt_svc_info_vector.size());
1221 EXPECT_EQ(kProtoQUIC, alt_svc_info_vector[0].alternative_service().protocol);
1222 EXPECT_EQ(1u, alt_svc_info_vector[0].advertised_versions().size());
1223 EXPECT_EQ(unsupported_version,
1224 alt_svc_info_vector[0].advertised_versions()[0]);
1225
1226 // First request should still be sent via TCP as the QUIC version advertised
1227 // in the stored AlternativeService is not supported by the client. However,
1228 // the response from the server will advertise new Alt-Svc with supported
1229 // versions.
1230 std::string advertised_versions_list_str =
1231 GenerateQuicVersionsListForAltSvcHeader(AllSupportedVersions());
1232 std::string altsvc_header =
1233 base::StringPrintf("Alt-Svc: quic=\":443\"; v=\"%s\"\r\n\r\n",
1234 advertised_versions_list_str.c_str());
1235 MockRead http_reads[] = {
1236 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(altsvc_header.c_str()),
1237 MockRead("hello world"),
1238 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
1239 MockRead(ASYNC, OK)};
1240
1241 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr,
1242 0);
1243 socket_factory_.AddSocketDataProvider(&http_data);
1244 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
1245
1246 // Second request should be sent via QUIC as a new list of verions supported
1247 // by the client has been advertised by the server.
1248 MockQuicData mock_quic_data;
1249 QuicStreamOffset header_stream_offset = 0;
1250 mock_quic_data.AddWrite(
1251 ConstructInitialSettingsPacket(1, &header_stream_offset));
1252 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket(
1253 2, GetNthClientInitiatedStreamId(0), true, true,
1254 GetRequestHeaders("GET", "https", "/"), &header_stream_offset));
1255 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket(
1256 1, GetNthClientInitiatedStreamId(0), false, false,
1257 GetResponseHeaders("200 OK")));
1258 mock_quic_data.AddRead(ConstructServerDataPacket(
1259 2, GetNthClientInitiatedStreamId(0), false, true, 0, "hello!"));
1260 mock_quic_data.AddWrite(ConstructClientAckPacket(3, 2, 1, 1));
1261 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read
1262 mock_quic_data.AddRead(ASYNC, 0); // EOF
1263
1264 mock_quic_data.AddSocketDataToFactory(&socket_factory_);
1265
1266 AddHangingNonAlternateProtocolSocketData();
1267
1268 CreateSession(supported_versions_);
1269
1270 SendRequestAndExpectHttpResponse("hello world");
1271 SendRequestAndExpectQuicResponse("hello!");
1272
1273 // Check alternative service list is updated with new versions.
1274 alt_svc_info_vector =
1275 session_->http_server_properties()->GetAlternativeServiceInfos(server);
1276 EXPECT_EQ(1u, alt_svc_info_vector.size());
1277 EXPECT_EQ(kProtoQUIC, alt_svc_info_vector[0].alternative_service().protocol);
1278 EXPECT_EQ(2u, alt_svc_info_vector[0].advertised_versions().size());
1279 // Advertised versions will be lised in a sorted order.
1280 std::sort(supported_versions_.begin(), supported_versions_.end());
1281 EXPECT_EQ(supported_versions_[0],
1282 alt_svc_info_vector[0].advertised_versions()[0]);
1283 EXPECT_EQ(supported_versions_[1],
1284 alt_svc_info_vector[0].advertised_versions()[1]);
1285 }
1286
1193 // Regression test for https://crbug.com/546991. 1287 // Regression test for https://crbug.com/546991.
1194 // The server might not be able to serve a request on an alternative connection, 1288 // The server might not be able to serve a request on an alternative connection,
1195 // and might send a 421 Misdirected Request response status to indicate this. 1289 // and might send a 421 Misdirected Request response status to indicate this.
1196 // HttpNetworkTransaction should reset the request and retry without using 1290 // HttpNetworkTransaction should reset the request and retry without using
1197 // alternative services. 1291 // alternative services.
1198 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) { 1292 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) {
1199 // Set up alternative service to use QUIC. 1293 // Set up alternative service to use QUIC.
1200 // Note that |origins_to_force_quic_on| cannot be used in this test, because 1294 // Note that |origins_to_force_quic_on| cannot be used in this test, because
1201 // that overrides |enable_alternative_services|. 1295 // that overrides |enable_alternative_services|.
1202 url::SchemeHostPort server(request_.url); 1296 url::SchemeHostPort server(request_.url);
(...skipping 3987 matching lines...) Expand 10 before | Expand all | Expand 10 after
5190 5284
5191 request_.url = GURL("https://mail.example.org/pushed.jpg"); 5285 request_.url = GURL("https://mail.example.org/pushed.jpg");
5192 ChunkedUploadDataStream upload_data(0); 5286 ChunkedUploadDataStream upload_data(0);
5193 upload_data.AppendData("1", 1, true); 5287 upload_data.AppendData("1", 1, true);
5194 request_.upload_data_stream = &upload_data; 5288 request_.upload_data_stream = &upload_data;
5195 SendRequestAndExpectQuicResponse("and hello!"); 5289 SendRequestAndExpectQuicResponse("and hello!");
5196 } 5290 }
5197 5291
5198 } // namespace test 5292 } // namespace test
5199 } // namespace net 5293 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698