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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 2901093004: Add and persist a new field in AlternativeServiceInfo to list QUIC verisons advertised (Closed)
Patch Set: self review Created 3 years, 7 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 | « no previous file | net/http/http_server_properties.h » ('j') | net/http/http_server_properties.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 9213 matching lines...) Expand 10 before | Expand all | Expand 10 after
9224 std::unique_ptr<HttpNetworkSession> SetupSessionForGroupNameTests( 9224 std::unique_ptr<HttpNetworkSession> SetupSessionForGroupNameTests(
9225 SpdySessionDependencies* session_deps_) { 9225 SpdySessionDependencies* session_deps_) {
9226 std::unique_ptr<HttpNetworkSession> session(CreateSession(session_deps_)); 9226 std::unique_ptr<HttpNetworkSession> session(CreateSession(session_deps_));
9227 9227
9228 HttpServerProperties* http_server_properties = 9228 HttpServerProperties* http_server_properties =
9229 session->http_server_properties(); 9229 session->http_server_properties();
9230 AlternativeService alternative_service(kProtoHTTP2, "", 444); 9230 AlternativeService alternative_service(kProtoHTTP2, "", 444);
9231 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9231 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9232 http_server_properties->SetAlternativeService( 9232 http_server_properties->SetAlternativeService(
9233 url::SchemeHostPort("https", "host.with.alternate", 443), 9233 url::SchemeHostPort("https", "host.with.alternate", 443),
9234 alternative_service, expiration); 9234 alternative_service, expiration,
9235 HttpNetworkSession::Params().quic_supported_versions);
9235 9236
9236 return session; 9237 return session;
9237 } 9238 }
9238 9239
9239 int GroupNameTransactionHelper(const std::string& url, 9240 int GroupNameTransactionHelper(const std::string& url,
9240 HttpNetworkSession* session) { 9241 HttpNetworkSession* session) {
9241 HttpRequestInfo request; 9242 HttpRequestInfo request;
9242 request.method = "GET"; 9243 request.method = "GET";
9243 request.url = GURL(url); 9244 request.url = GURL(url);
9244 9245
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
10187 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 10188 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
10188 10189
10189 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10190 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10190 10191
10191 HttpServerProperties* http_server_properties = 10192 HttpServerProperties* http_server_properties =
10192 session->http_server_properties(); 10193 session->http_server_properties();
10193 AlternativeService alternative_service(kProtoHTTP2, "different.example.org", 10194 AlternativeService alternative_service(kProtoHTTP2, "different.example.org",
10194 444); 10195 444);
10195 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10196 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10196 http_server_properties->SetAlternativeService( 10197 http_server_properties->SetAlternativeService(
10197 url::SchemeHostPort(request.url), alternative_service, expiration); 10198 url::SchemeHostPort(request.url), alternative_service, expiration,
10199 HttpNetworkSession::Params().quic_supported_versions);
10198 10200
10199 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10201 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10200 TestCompletionCallback callback; 10202 TestCompletionCallback callback;
10201 10203
10202 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10204 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10203 // Alternative service is not used, request fails. 10205 // Alternative service is not used, request fails.
10204 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED)); 10206 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED));
10205 } 10207 }
10206 10208
10207 // Regression test for https://crbug.com/615497: 10209 // Regression test for https://crbug.com/615497:
(...skipping 18 matching lines...) Expand all
10226 0); 10228 0);
10227 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 10229 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
10228 10230
10229 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10231 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10230 10232
10231 HttpServerProperties* http_server_properties = 10233 HttpServerProperties* http_server_properties =
10232 session->http_server_properties(); 10234 session->http_server_properties();
10233 AlternativeService alternative_service(kProtoHTTP2, "", 444); 10235 AlternativeService alternative_service(kProtoHTTP2, "", 444);
10234 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10236 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10235 http_server_properties->SetAlternativeService( 10237 http_server_properties->SetAlternativeService(
10236 url::SchemeHostPort(request.url), alternative_service, expiration); 10238 url::SchemeHostPort(request.url), alternative_service, expiration,
10239 HttpNetworkSession::Params().quic_supported_versions);
10237 10240
10238 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10241 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10239 TestCompletionCallback callback; 10242 TestCompletionCallback callback;
10240 10243
10241 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10244 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10242 // Alternative service is not used, request fails. 10245 // Alternative service is not used, request fails.
10243 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED)); 10246 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED));
10244 } 10247 }
10245 10248
10246 TEST_F(HttpNetworkTransactionTest, ClearAlternativeServices) { 10249 TEST_F(HttpNetworkTransactionTest, ClearAlternativeServices) {
10247 // Set an alternative service for origin. 10250 // Set an alternative service for origin.
10248 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10251 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10249 HttpServerProperties* http_server_properties = 10252 HttpServerProperties* http_server_properties =
10250 session->http_server_properties(); 10253 session->http_server_properties();
10251 url::SchemeHostPort test_server("https", "www.example.org", 443); 10254 url::SchemeHostPort test_server("https", "www.example.org", 443);
10252 AlternativeService alternative_service(kProtoQUIC, "", 80); 10255 AlternativeService alternative_service(kProtoQUIC, "", 80);
10253 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10256 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10254 http_server_properties->SetAlternativeService( 10257 http_server_properties->SetAlternativeService(
10255 test_server, alternative_service, expiration); 10258 test_server, alternative_service, expiration,
10259 HttpNetworkSession::Params().quic_supported_versions);
10256 EXPECT_EQ( 10260 EXPECT_EQ(
10257 1u, 10261 1u,
10258 http_server_properties->GetAlternativeServiceInfos(test_server).size()); 10262 http_server_properties->GetAlternativeServiceInfos(test_server).size());
10259 10263
10260 // Send a clear header. 10264 // Send a clear header.
10261 MockRead data_reads[] = { 10265 MockRead data_reads[] = {
10262 MockRead("HTTP/1.1 200 OK\r\n"), 10266 MockRead("HTTP/1.1 200 OK\r\n"),
10263 MockRead("Alt-Svc: clear\r\n"), 10267 MockRead("Alt-Svc: clear\r\n"),
10264 MockRead("\r\n"), 10268 MockRead("\r\n"),
10265 MockRead("hello world"), 10269 MockRead("hello world"),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
10387 StaticSocketDataProvider data_refused; 10391 StaticSocketDataProvider data_refused;
10388 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 10392 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
10389 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 10393 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
10390 10394
10391 // Set up a QUIC alternative service for server. 10395 // Set up a QUIC alternative service for server.
10392 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10396 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10393 HttpServerProperties* http_server_properties = 10397 HttpServerProperties* http_server_properties =
10394 session->http_server_properties(); 10398 session->http_server_properties();
10395 AlternativeService alternative_service(kProtoQUIC, alternative); 10399 AlternativeService alternative_service(kProtoQUIC, alternative);
10396 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10400 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10397 http_server_properties->SetAlternativeService(server, alternative_service, 10401 http_server_properties->SetAlternativeService(
10398 expiration); 10402 server, alternative_service, expiration,
10403 HttpNetworkSession::Params().quic_supported_versions);
10399 // Mark the QUIC alternative service as broken. 10404 // Mark the QUIC alternative service as broken.
10400 http_server_properties->MarkAlternativeServiceBroken(alternative_service); 10405 http_server_properties->MarkAlternativeServiceBroken(alternative_service);
10401 10406
10402 HttpRequestInfo request; 10407 HttpRequestInfo request;
10403 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10408 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10404 request.method = "GET"; 10409 request.method = "GET";
10405 request.url = GURL(origin_url); 10410 request.url = GURL(origin_url);
10406 TestCompletionCallback callback; 10411 TestCompletionCallback callback;
10407 NetErrorDetails details; 10412 NetErrorDetails details;
10408 EXPECT_FALSE(details.quic_broken); 10413 EXPECT_FALSE(details.quic_broken);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
10448 10453
10449 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10454 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10450 HttpServerProperties* http_server_properties = 10455 HttpServerProperties* http_server_properties =
10451 session->http_server_properties(); 10456 session->http_server_properties();
10452 10457
10453 // Set up two QUIC alternative services for server. 10458 // Set up two QUIC alternative services for server.
10454 AlternativeServiceInfoVector alternative_service_info_vector; 10459 AlternativeServiceInfoVector alternative_service_info_vector;
10455 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10460 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10456 10461
10457 AlternativeService alternative_service1(kProtoQUIC, alternative1); 10462 AlternativeService alternative_service1(kProtoQUIC, alternative1);
10458 AlternativeServiceInfo alternative_service_info1(alternative_service1, 10463 AlternativeServiceInfo alternative_service_info1(
10459 expiration); 10464 alternative_service1, expiration,
10465 HttpNetworkSession::Params().quic_supported_versions);
10460 alternative_service_info_vector.push_back(alternative_service_info1); 10466 alternative_service_info_vector.push_back(alternative_service_info1);
10461 AlternativeService alternative_service2(kProtoQUIC, alternative2); 10467 AlternativeService alternative_service2(kProtoQUIC, alternative2);
10462 AlternativeServiceInfo alternative_service_info2(alternative_service2, 10468 AlternativeServiceInfo alternative_service_info2(
10463 expiration); 10469 alternative_service2, expiration,
10470 HttpNetworkSession::Params().quic_supported_versions);
10464 alternative_service_info_vector.push_back(alternative_service_info2); 10471 alternative_service_info_vector.push_back(alternative_service_info2);
10465 10472
10466 http_server_properties->SetAlternativeServices( 10473 http_server_properties->SetAlternativeServices(
10467 server, alternative_service_info_vector); 10474 server, alternative_service_info_vector);
10468 10475
10469 // Mark one of the QUIC alternative service as broken. 10476 // Mark one of the QUIC alternative service as broken.
10470 http_server_properties->MarkAlternativeServiceBroken(alternative_service1); 10477 http_server_properties->MarkAlternativeServiceBroken(alternative_service1);
10471 EXPECT_EQ(2u, 10478 EXPECT_EQ(2u,
10472 http_server_properties->GetAlternativeServiceInfos(server).size()); 10479 http_server_properties->GetAlternativeServiceInfos(server).size());
10473 10480
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
10510 10517
10511 HttpServerProperties* http_server_properties = 10518 HttpServerProperties* http_server_properties =
10512 session->http_server_properties(); 10519 session->http_server_properties();
10513 const url::SchemeHostPort server(request.url); 10520 const url::SchemeHostPort server(request.url);
10514 // Port must be < 1024, or the header will be ignored (since initial port was 10521 // Port must be < 1024, or the header will be ignored (since initial port was
10515 // port 80 (another restricted port). 10522 // port 80 (another restricted port).
10516 const AlternativeService alternative_service( 10523 const AlternativeService alternative_service(
10517 kProtoHTTP2, "www.example.org", 10524 kProtoHTTP2, "www.example.org",
10518 666); // Port is ignored by MockConnect anyway. 10525 666); // Port is ignored by MockConnect anyway.
10519 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10526 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10520 http_server_properties->SetAlternativeService(server, alternative_service, 10527 http_server_properties->SetAlternativeService(
10521 expiration); 10528 server, alternative_service, expiration,
10529 HttpNetworkSession::Params().quic_supported_versions);
10522 10530
10523 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10531 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10524 TestCompletionCallback callback; 10532 TestCompletionCallback callback;
10525 10533
10526 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10534 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10527 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10535 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10528 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10536 EXPECT_THAT(callback.WaitForResult(), IsOk());
10529 10537
10530 const HttpResponseInfo* response = trans.GetResponseInfo(); 10538 const HttpResponseInfo* response = trans.GetResponseInfo();
10531 ASSERT_TRUE(response); 10539 ASSERT_TRUE(response);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
10575 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10583 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10576 10584
10577 HttpServerProperties* http_server_properties = 10585 HttpServerProperties* http_server_properties =
10578 session->http_server_properties(); 10586 session->http_server_properties();
10579 const int kUnrestrictedAlternatePort = 1024; 10587 const int kUnrestrictedAlternatePort = 1024;
10580 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10588 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10581 kUnrestrictedAlternatePort); 10589 kUnrestrictedAlternatePort);
10582 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10590 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10583 http_server_properties->SetAlternativeService( 10591 http_server_properties->SetAlternativeService(
10584 url::SchemeHostPort(restricted_port_request.url), alternative_service, 10592 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10585 expiration); 10593 expiration, HttpNetworkSession::Params().quic_supported_versions);
10586 10594
10587 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10595 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10588 TestCompletionCallback callback; 10596 TestCompletionCallback callback;
10589 10597
10590 int rv = trans.Start(&restricted_port_request, callback.callback(), 10598 int rv = trans.Start(&restricted_port_request, callback.callback(),
10591 NetLogWithSource()); 10599 NetLogWithSource());
10592 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10600 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10593 // Invalid change to unrestricted port should fail. 10601 // Invalid change to unrestricted port should fail.
10594 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_REFUSED)); 10602 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_REFUSED));
10595 } 10603 }
(...skipping 29 matching lines...) Expand all
10625 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10633 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10626 10634
10627 HttpServerProperties* http_server_properties = 10635 HttpServerProperties* http_server_properties =
10628 session->http_server_properties(); 10636 session->http_server_properties();
10629 const int kUnrestrictedAlternatePort = 1024; 10637 const int kUnrestrictedAlternatePort = 1024;
10630 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10638 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10631 kUnrestrictedAlternatePort); 10639 kUnrestrictedAlternatePort);
10632 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10640 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10633 http_server_properties->SetAlternativeService( 10641 http_server_properties->SetAlternativeService(
10634 url::SchemeHostPort(restricted_port_request.url), alternative_service, 10642 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10635 expiration); 10643 expiration, HttpNetworkSession::Params().quic_supported_versions);
10636 10644
10637 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10645 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10638 TestCompletionCallback callback; 10646 TestCompletionCallback callback;
10639 10647
10640 EXPECT_EQ(ERR_IO_PENDING, 10648 EXPECT_EQ(ERR_IO_PENDING,
10641 trans.Start(&restricted_port_request, callback.callback(), 10649 trans.Start(&restricted_port_request, callback.callback(),
10642 NetLogWithSource())); 10650 NetLogWithSource()));
10643 // Change to unrestricted port should succeed. 10651 // Change to unrestricted port should succeed.
10644 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10652 EXPECT_THAT(callback.WaitForResult(), IsOk());
10645 } 10653 }
(...skipping 28 matching lines...) Expand all
10674 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10682 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10675 10683
10676 HttpServerProperties* http_server_properties = 10684 HttpServerProperties* http_server_properties =
10677 session->http_server_properties(); 10685 session->http_server_properties();
10678 const int kRestrictedAlternatePort = 80; 10686 const int kRestrictedAlternatePort = 80;
10679 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10687 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10680 kRestrictedAlternatePort); 10688 kRestrictedAlternatePort);
10681 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10689 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10682 http_server_properties->SetAlternativeService( 10690 http_server_properties->SetAlternativeService(
10683 url::SchemeHostPort(restricted_port_request.url), alternative_service, 10691 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10684 expiration); 10692 expiration, HttpNetworkSession::Params().quic_supported_versions);
10685 10693
10686 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10694 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10687 TestCompletionCallback callback; 10695 TestCompletionCallback callback;
10688 10696
10689 int rv = trans.Start(&restricted_port_request, callback.callback(), 10697 int rv = trans.Start(&restricted_port_request, callback.callback(),
10690 NetLogWithSource()); 10698 NetLogWithSource());
10691 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10699 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10692 // Valid change to restricted port should pass. 10700 // Valid change to restricted port should pass.
10693 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10701 EXPECT_THAT(callback.WaitForResult(), IsOk());
10694 } 10702 }
(...skipping 28 matching lines...) Expand all
10723 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10731 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10724 10732
10725 HttpServerProperties* http_server_properties = 10733 HttpServerProperties* http_server_properties =
10726 session->http_server_properties(); 10734 session->http_server_properties();
10727 const int kRestrictedAlternatePort = 80; 10735 const int kRestrictedAlternatePort = 80;
10728 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10736 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10729 kRestrictedAlternatePort); 10737 kRestrictedAlternatePort);
10730 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10738 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10731 http_server_properties->SetAlternativeService( 10739 http_server_properties->SetAlternativeService(
10732 url::SchemeHostPort(unrestricted_port_request.url), alternative_service, 10740 url::SchemeHostPort(unrestricted_port_request.url), alternative_service,
10733 expiration); 10741 expiration, HttpNetworkSession::Params().quic_supported_versions);
10734 10742
10735 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10743 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10736 TestCompletionCallback callback; 10744 TestCompletionCallback callback;
10737 10745
10738 int rv = trans.Start(&unrestricted_port_request, callback.callback(), 10746 int rv = trans.Start(&unrestricted_port_request, callback.callback(),
10739 NetLogWithSource()); 10747 NetLogWithSource());
10740 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10748 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10741 // Valid change to restricted port should pass. 10749 // Valid change to restricted port should pass.
10742 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10750 EXPECT_THAT(callback.WaitForResult(), IsOk());
10743 } 10751 }
(...skipping 28 matching lines...) Expand all
10772 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10780 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10773 10781
10774 HttpServerProperties* http_server_properties = 10782 HttpServerProperties* http_server_properties =
10775 session->http_server_properties(); 10783 session->http_server_properties();
10776 const int kUnrestrictedAlternatePort = 1025; 10784 const int kUnrestrictedAlternatePort = 1025;
10777 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10785 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10778 kUnrestrictedAlternatePort); 10786 kUnrestrictedAlternatePort);
10779 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10787 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10780 http_server_properties->SetAlternativeService( 10788 http_server_properties->SetAlternativeService(
10781 url::SchemeHostPort(unrestricted_port_request.url), alternative_service, 10789 url::SchemeHostPort(unrestricted_port_request.url), alternative_service,
10782 expiration); 10790 expiration, HttpNetworkSession::Params().quic_supported_versions);
10783 10791
10784 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10792 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10785 TestCompletionCallback callback; 10793 TestCompletionCallback callback;
10786 10794
10787 int rv = trans.Start(&unrestricted_port_request, callback.callback(), 10795 int rv = trans.Start(&unrestricted_port_request, callback.callback(),
10788 NetLogWithSource()); 10796 NetLogWithSource());
10789 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10797 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10790 // Valid change to an unrestricted port should pass. 10798 // Valid change to an unrestricted port should pass.
10791 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10799 EXPECT_THAT(callback.WaitForResult(), IsOk());
10792 } 10800 }
(...skipping 19 matching lines...) Expand all
10812 10820
10813 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10821 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10814 10822
10815 HttpServerProperties* http_server_properties = 10823 HttpServerProperties* http_server_properties =
10816 session->http_server_properties(); 10824 session->http_server_properties();
10817 const int kUnsafePort = 7; 10825 const int kUnsafePort = 7;
10818 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10826 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10819 kUnsafePort); 10827 kUnsafePort);
10820 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10828 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10821 http_server_properties->SetAlternativeService( 10829 http_server_properties->SetAlternativeService(
10822 url::SchemeHostPort(request.url), alternative_service, expiration); 10830 url::SchemeHostPort(request.url), alternative_service, expiration,
10831 HttpNetworkSession::Params().quic_supported_versions);
10823 10832
10824 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10833 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10825 TestCompletionCallback callback; 10834 TestCompletionCallback callback;
10826 10835
10827 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10836 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10828 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10837 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10829 // The HTTP request should succeed. 10838 // The HTTP request should succeed.
10830 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10839 EXPECT_THAT(callback.WaitForResult(), IsOk());
10831 10840
10832 const HttpResponseInfo* response = trans.GetResponseInfo(); 10841 const HttpResponseInfo* response = trans.GetResponseInfo();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
11169 11178
11170 // Configure alternative service with a hostname that is not bypassed by the 11179 // Configure alternative service with a hostname that is not bypassed by the
11171 // proxy. 11180 // proxy.
11172 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11181 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11173 HttpServerProperties* http_server_properties = 11182 HttpServerProperties* http_server_properties =
11174 session->http_server_properties(); 11183 session->http_server_properties();
11175 url::SchemeHostPort server("https", "www.example.org", 443); 11184 url::SchemeHostPort server("https", "www.example.org", 443);
11176 HostPortPair alternative("www.example.com", 443); 11185 HostPortPair alternative("www.example.com", 443);
11177 AlternativeService alternative_service(kProtoHTTP2, alternative); 11186 AlternativeService alternative_service(kProtoHTTP2, alternative);
11178 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 11187 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
11179 http_server_properties->SetAlternativeService(server, alternative_service, 11188 http_server_properties->SetAlternativeService(
11180 expiration); 11189 server, alternative_service, expiration,
11190 HttpNetworkSession::Params().quic_supported_versions);
11181 11191
11182 // Non-alternative job should hang. 11192 // Non-alternative job should hang.
11183 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); 11193 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
11184 StaticSocketDataProvider hanging_alternate_protocol_socket(nullptr, 0, 11194 StaticSocketDataProvider hanging_alternate_protocol_socket(nullptr, 0,
11185 nullptr, 0); 11195 nullptr, 0);
11186 hanging_alternate_protocol_socket.set_connect_data(never_finishing_connect); 11196 hanging_alternate_protocol_socket.set_connect_data(never_finishing_connect);
11187 session_deps_.socket_factory->AddSocketDataProvider( 11197 session_deps_.socket_factory->AddSocketDataProvider(
11188 &hanging_alternate_protocol_socket); 11198 &hanging_alternate_protocol_socket);
11189 11199
11190 AddSSLSocketData(); 11200 AddSSLSocketData();
(...skipping 2881 matching lines...) Expand 10 before | Expand all | Expand 10 after
14072 StaticSocketDataProvider data_refused; 14082 StaticSocketDataProvider data_refused;
14073 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 14083 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
14074 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 14084 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
14075 14085
14076 // Set up alternative service for server. 14086 // Set up alternative service for server.
14077 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14087 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14078 HttpServerProperties* http_server_properties = 14088 HttpServerProperties* http_server_properties =
14079 session->http_server_properties(); 14089 session->http_server_properties();
14080 AlternativeService alternative_service(kProtoHTTP2, alternative); 14090 AlternativeService alternative_service(kProtoHTTP2, alternative);
14081 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 14091 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
14082 http_server_properties->SetAlternativeService(server, alternative_service, 14092 http_server_properties->SetAlternativeService(
14083 expiration); 14093 server, alternative_service, expiration,
14094 HttpNetworkSession::Params().quic_supported_versions);
14084 14095
14085 HttpRequestInfo request; 14096 HttpRequestInfo request;
14086 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 14097 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
14087 request.method = "GET"; 14098 request.method = "GET";
14088 request.url = GURL("https://www.example.org:443"); 14099 request.url = GURL("https://www.example.org:443");
14089 TestCompletionCallback callback; 14100 TestCompletionCallback callback;
14090 14101
14091 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is 14102 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is
14092 // negotiated, the alternate Job should fail with ERR_ALPN_NEGOTIATION_FAILED. 14103 // negotiated, the alternate Job should fail with ERR_ALPN_NEGOTIATION_FAILED.
14093 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 14104 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
14139 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 14150 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
14140 http_writes, arraysize(http_writes)); 14151 http_writes, arraysize(http_writes));
14141 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 14152 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
14142 14153
14143 // Set up alternative service for server. 14154 // Set up alternative service for server.
14144 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14155 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14145 HttpServerProperties* http_server_properties = 14156 HttpServerProperties* http_server_properties =
14146 session->http_server_properties(); 14157 session->http_server_properties();
14147 AlternativeService alternative_service(kProtoHTTP2, alternative); 14158 AlternativeService alternative_service(kProtoHTTP2, alternative);
14148 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 14159 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
14149 http_server_properties->SetAlternativeService(server, alternative_service, 14160 http_server_properties->SetAlternativeService(
14150 expiration); 14161 server, alternative_service, expiration,
14162 HttpNetworkSession::Params().quic_supported_versions);
14151 14163
14152 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 14164 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
14153 HttpRequestInfo request1; 14165 HttpRequestInfo request1;
14154 request1.method = "GET"; 14166 request1.method = "GET";
14155 request1.url = GURL("https://www.example.org:443"); 14167 request1.url = GURL("https://www.example.org:443");
14156 request1.load_flags = 0; 14168 request1.load_flags = 0;
14157 TestCompletionCallback callback1; 14169 TestCompletionCallback callback1;
14158 14170
14159 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource()); 14171 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource());
14160 rv = callback1.GetResult(rv); 14172 rv = callback1.GetResult(rv);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
14246 StaticSocketDataProvider data_refused; 14258 StaticSocketDataProvider data_refused;
14247 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 14259 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
14248 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 14260 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
14249 14261
14250 // Set up alternative service for server. 14262 // Set up alternative service for server.
14251 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14263 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14252 HttpServerProperties* http_server_properties = 14264 HttpServerProperties* http_server_properties =
14253 session->http_server_properties(); 14265 session->http_server_properties();
14254 AlternativeService alternative_service(kProtoHTTP2, alternative); 14266 AlternativeService alternative_service(kProtoHTTP2, alternative);
14255 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 14267 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
14256 http_server_properties->SetAlternativeService(server, alternative_service, 14268 http_server_properties->SetAlternativeService(
14257 expiration); 14269 server, alternative_service, expiration,
14270 HttpNetworkSession::Params().quic_supported_versions);
14258 14271
14259 // First transaction to alternative to open an HTTP/1.1 socket. 14272 // First transaction to alternative to open an HTTP/1.1 socket.
14260 HttpRequestInfo request1; 14273 HttpRequestInfo request1;
14261 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 14274 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
14262 request1.method = "GET"; 14275 request1.method = "GET";
14263 request1.url = GURL(alternative_url); 14276 request1.url = GURL(alternative_url);
14264 request1.load_flags = 0; 14277 request1.load_flags = 0;
14265 TestCompletionCallback callback1; 14278 TestCompletionCallback callback1;
14266 14279
14267 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource()); 14280 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource());
(...skipping 2587 matching lines...) Expand 10 before | Expand all | Expand 10 after
16855 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "gzip", 16868 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "gzip",
16856 "", false); 16869 "", false);
16857 } 16870 }
16858 16871
16859 TEST_F(HttpNetworkTransactionTest, MatchContentEncoding4) { 16872 TEST_F(HttpNetworkTransactionTest, MatchContentEncoding4) {
16860 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "gzip", 16873 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "gzip",
16861 "www.foo.com/other", true); 16874 "www.foo.com/other", true);
16862 } 16875 }
16863 16876
16864 } // namespace net 16877 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_server_properties.h » ('j') | net/http/http_server_properties.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698