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

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: fix compile in components Created 3 years, 6 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
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 9222 matching lines...) Expand 10 before | Expand all | Expand 10 after
9233 std::unique_ptr<HttpNetworkSession> SetupSessionForGroupNameTests( 9233 std::unique_ptr<HttpNetworkSession> SetupSessionForGroupNameTests(
9234 SpdySessionDependencies* session_deps_) { 9234 SpdySessionDependencies* session_deps_) {
9235 std::unique_ptr<HttpNetworkSession> session(CreateSession(session_deps_)); 9235 std::unique_ptr<HttpNetworkSession> session(CreateSession(session_deps_));
9236 9236
9237 HttpServerProperties* http_server_properties = 9237 HttpServerProperties* http_server_properties =
9238 session->http_server_properties(); 9238 session->http_server_properties();
9239 AlternativeService alternative_service(kProtoHTTP2, "", 444); 9239 AlternativeService alternative_service(kProtoHTTP2, "", 444);
9240 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9240 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9241 http_server_properties->SetAlternativeService( 9241 http_server_properties->SetAlternativeService(
9242 url::SchemeHostPort("https", "host.with.alternate", 443), 9242 url::SchemeHostPort("https", "host.with.alternate", 443),
9243 alternative_service, expiration); 9243 alternative_service, expiration,
9244 HttpNetworkSession::Params().quic_supported_versions);
Ryan Hamilton 2017/06/07 20:52:23 Hm, I'm not sure about this. Can we get the params
Zhongyi Shi 2017/06/08 23:11:16 Thanks for catching this. This change was added in
9244 9245
9245 return session; 9246 return session;
9246 } 9247 }
9247 9248
9248 int GroupNameTransactionHelper(const std::string& url, 9249 int GroupNameTransactionHelper(const std::string& url,
9249 HttpNetworkSession* session) { 9250 HttpNetworkSession* session) {
9250 HttpRequestInfo request; 9251 HttpRequestInfo request;
9251 request.method = "GET"; 9252 request.method = "GET";
9252 request.url = GURL(url); 9253 request.url = GURL(url);
9253 9254
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
10191 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 10192 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
10192 10193
10193 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10194 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10194 10195
10195 HttpServerProperties* http_server_properties = 10196 HttpServerProperties* http_server_properties =
10196 session->http_server_properties(); 10197 session->http_server_properties();
10197 AlternativeService alternative_service(kProtoHTTP2, "different.example.org", 10198 AlternativeService alternative_service(kProtoHTTP2, "different.example.org",
10198 444); 10199 444);
10199 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10200 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10200 http_server_properties->SetAlternativeService( 10201 http_server_properties->SetAlternativeService(
10201 url::SchemeHostPort(request.url), alternative_service, expiration); 10202 url::SchemeHostPort(request.url), alternative_service, expiration,
10203 HttpNetworkSession::Params().quic_supported_versions);
10202 10204
10203 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10205 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10204 TestCompletionCallback callback; 10206 TestCompletionCallback callback;
10205 10207
10206 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10208 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10207 // Alternative service is not used, request fails. 10209 // Alternative service is not used, request fails.
10208 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED)); 10210 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED));
10209 } 10211 }
10210 10212
10211 // Regression test for https://crbug.com/615497: 10213 // Regression test for https://crbug.com/615497:
(...skipping 18 matching lines...) Expand all
10230 0); 10232 0);
10231 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 10233 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
10232 10234
10233 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10235 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10234 10236
10235 HttpServerProperties* http_server_properties = 10237 HttpServerProperties* http_server_properties =
10236 session->http_server_properties(); 10238 session->http_server_properties();
10237 AlternativeService alternative_service(kProtoHTTP2, "", 444); 10239 AlternativeService alternative_service(kProtoHTTP2, "", 444);
10238 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10240 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10239 http_server_properties->SetAlternativeService( 10241 http_server_properties->SetAlternativeService(
10240 url::SchemeHostPort(request.url), alternative_service, expiration); 10242 url::SchemeHostPort(request.url), alternative_service, expiration,
10243 HttpNetworkSession::Params().quic_supported_versions);
10241 10244
10242 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10245 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10243 TestCompletionCallback callback; 10246 TestCompletionCallback callback;
10244 10247
10245 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10248 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10246 // Alternative service is not used, request fails. 10249 // Alternative service is not used, request fails.
10247 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED)); 10250 EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED));
10248 } 10251 }
10249 10252
10250 TEST_F(HttpNetworkTransactionTest, ClearAlternativeServices) { 10253 TEST_F(HttpNetworkTransactionTest, ClearAlternativeServices) {
10251 // Set an alternative service for origin. 10254 // Set an alternative service for origin.
10252 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10255 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10253 HttpServerProperties* http_server_properties = 10256 HttpServerProperties* http_server_properties =
10254 session->http_server_properties(); 10257 session->http_server_properties();
10255 url::SchemeHostPort test_server("https", "www.example.org", 443); 10258 url::SchemeHostPort test_server("https", "www.example.org", 443);
10256 AlternativeService alternative_service(kProtoQUIC, "", 80); 10259 AlternativeService alternative_service(kProtoQUIC, "", 80);
10257 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10260 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10258 http_server_properties->SetAlternativeService( 10261 http_server_properties->SetAlternativeService(
10259 test_server, alternative_service, expiration); 10262 test_server, alternative_service, expiration,
10263 HttpNetworkSession::Params().quic_supported_versions);
10260 EXPECT_EQ( 10264 EXPECT_EQ(
10261 1u, 10265 1u,
10262 http_server_properties->GetAlternativeServiceInfos(test_server).size()); 10266 http_server_properties->GetAlternativeServiceInfos(test_server).size());
10263 10267
10264 // Send a clear header. 10268 // Send a clear header.
10265 MockRead data_reads[] = { 10269 MockRead data_reads[] = {
10266 MockRead("HTTP/1.1 200 OK\r\n"), 10270 MockRead("HTTP/1.1 200 OK\r\n"),
10267 MockRead("Alt-Svc: clear\r\n"), 10271 MockRead("Alt-Svc: clear\r\n"),
10268 MockRead("\r\n"), 10272 MockRead("\r\n"),
10269 MockRead("hello world"), 10273 MockRead("hello world"),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
10391 StaticSocketDataProvider data_refused; 10395 StaticSocketDataProvider data_refused;
10392 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 10396 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
10393 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 10397 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
10394 10398
10395 // Set up a QUIC alternative service for server. 10399 // Set up a QUIC alternative service for server.
10396 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10400 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10397 HttpServerProperties* http_server_properties = 10401 HttpServerProperties* http_server_properties =
10398 session->http_server_properties(); 10402 session->http_server_properties();
10399 AlternativeService alternative_service(kProtoQUIC, alternative); 10403 AlternativeService alternative_service(kProtoQUIC, alternative);
10400 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10404 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10401 http_server_properties->SetAlternativeService(server, alternative_service, 10405 http_server_properties->SetAlternativeService(
10402 expiration); 10406 server, alternative_service, expiration,
10407 HttpNetworkSession::Params().quic_supported_versions);
10403 // Mark the QUIC alternative service as broken. 10408 // Mark the QUIC alternative service as broken.
10404 http_server_properties->MarkAlternativeServiceBroken(alternative_service); 10409 http_server_properties->MarkAlternativeServiceBroken(alternative_service);
10405 10410
10406 HttpRequestInfo request; 10411 HttpRequestInfo request;
10407 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10412 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10408 request.method = "GET"; 10413 request.method = "GET";
10409 request.url = GURL(origin_url); 10414 request.url = GURL(origin_url);
10410 TestCompletionCallback callback; 10415 TestCompletionCallback callback;
10411 NetErrorDetails details; 10416 NetErrorDetails details;
10412 EXPECT_FALSE(details.quic_broken); 10417 EXPECT_FALSE(details.quic_broken);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
10514 10519
10515 HttpServerProperties* http_server_properties = 10520 HttpServerProperties* http_server_properties =
10516 session->http_server_properties(); 10521 session->http_server_properties();
10517 const url::SchemeHostPort server(request.url); 10522 const url::SchemeHostPort server(request.url);
10518 // Port must be < 1024, or the header will be ignored (since initial port was 10523 // Port must be < 1024, or the header will be ignored (since initial port was
10519 // port 80 (another restricted port). 10524 // port 80 (another restricted port).
10520 const AlternativeService alternative_service( 10525 const AlternativeService alternative_service(
10521 kProtoHTTP2, "www.example.org", 10526 kProtoHTTP2, "www.example.org",
10522 666); // Port is ignored by MockConnect anyway. 10527 666); // Port is ignored by MockConnect anyway.
10523 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10528 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10524 http_server_properties->SetAlternativeService(server, alternative_service, 10529 http_server_properties->SetAlternativeService(
10525 expiration); 10530 server, alternative_service, expiration,
10531 HttpNetworkSession::Params().quic_supported_versions);
10526 10532
10527 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10533 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10528 TestCompletionCallback callback; 10534 TestCompletionCallback callback;
10529 10535
10530 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10536 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10531 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10537 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10532 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10538 EXPECT_THAT(callback.WaitForResult(), IsOk());
10533 10539
10534 const HttpResponseInfo* response = trans.GetResponseInfo(); 10540 const HttpResponseInfo* response = trans.GetResponseInfo();
10535 ASSERT_TRUE(response); 10541 ASSERT_TRUE(response);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
10579 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10585 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10580 10586
10581 HttpServerProperties* http_server_properties = 10587 HttpServerProperties* http_server_properties =
10582 session->http_server_properties(); 10588 session->http_server_properties();
10583 const int kUnrestrictedAlternatePort = 1024; 10589 const int kUnrestrictedAlternatePort = 1024;
10584 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10590 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10585 kUnrestrictedAlternatePort); 10591 kUnrestrictedAlternatePort);
10586 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10592 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10587 http_server_properties->SetAlternativeService( 10593 http_server_properties->SetAlternativeService(
10588 url::SchemeHostPort(restricted_port_request.url), alternative_service, 10594 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10589 expiration); 10595 expiration, HttpNetworkSession::Params().quic_supported_versions);
10590 10596
10591 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10597 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10592 TestCompletionCallback callback; 10598 TestCompletionCallback callback;
10593 10599
10594 int rv = trans.Start(&restricted_port_request, callback.callback(), 10600 int rv = trans.Start(&restricted_port_request, callback.callback(),
10595 NetLogWithSource()); 10601 NetLogWithSource());
10596 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10602 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10597 // Invalid change to unrestricted port should fail. 10603 // Invalid change to unrestricted port should fail.
10598 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_REFUSED)); 10604 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_REFUSED));
10599 } 10605 }
(...skipping 29 matching lines...) Expand all
10629 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10635 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10630 10636
10631 HttpServerProperties* http_server_properties = 10637 HttpServerProperties* http_server_properties =
10632 session->http_server_properties(); 10638 session->http_server_properties();
10633 const int kUnrestrictedAlternatePort = 1024; 10639 const int kUnrestrictedAlternatePort = 1024;
10634 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10640 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10635 kUnrestrictedAlternatePort); 10641 kUnrestrictedAlternatePort);
10636 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10642 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10637 http_server_properties->SetAlternativeService( 10643 http_server_properties->SetAlternativeService(
10638 url::SchemeHostPort(restricted_port_request.url), alternative_service, 10644 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10639 expiration); 10645 expiration, HttpNetworkSession::Params().quic_supported_versions);
10640 10646
10641 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10647 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10642 TestCompletionCallback callback; 10648 TestCompletionCallback callback;
10643 10649
10644 EXPECT_EQ(ERR_IO_PENDING, 10650 EXPECT_EQ(ERR_IO_PENDING,
10645 trans.Start(&restricted_port_request, callback.callback(), 10651 trans.Start(&restricted_port_request, callback.callback(),
10646 NetLogWithSource())); 10652 NetLogWithSource()));
10647 // Change to unrestricted port should succeed. 10653 // Change to unrestricted port should succeed.
10648 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10654 EXPECT_THAT(callback.WaitForResult(), IsOk());
10649 } 10655 }
(...skipping 28 matching lines...) Expand all
10678 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10684 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10679 10685
10680 HttpServerProperties* http_server_properties = 10686 HttpServerProperties* http_server_properties =
10681 session->http_server_properties(); 10687 session->http_server_properties();
10682 const int kRestrictedAlternatePort = 80; 10688 const int kRestrictedAlternatePort = 80;
10683 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10689 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10684 kRestrictedAlternatePort); 10690 kRestrictedAlternatePort);
10685 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10691 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10686 http_server_properties->SetAlternativeService( 10692 http_server_properties->SetAlternativeService(
10687 url::SchemeHostPort(restricted_port_request.url), alternative_service, 10693 url::SchemeHostPort(restricted_port_request.url), alternative_service,
10688 expiration); 10694 expiration, HttpNetworkSession::Params().quic_supported_versions);
10689 10695
10690 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10696 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10691 TestCompletionCallback callback; 10697 TestCompletionCallback callback;
10692 10698
10693 int rv = trans.Start(&restricted_port_request, callback.callback(), 10699 int rv = trans.Start(&restricted_port_request, callback.callback(),
10694 NetLogWithSource()); 10700 NetLogWithSource());
10695 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10701 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10696 // Valid change to restricted port should pass. 10702 // Valid change to restricted port should pass.
10697 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10703 EXPECT_THAT(callback.WaitForResult(), IsOk());
10698 } 10704 }
(...skipping 28 matching lines...) Expand all
10727 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10733 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10728 10734
10729 HttpServerProperties* http_server_properties = 10735 HttpServerProperties* http_server_properties =
10730 session->http_server_properties(); 10736 session->http_server_properties();
10731 const int kRestrictedAlternatePort = 80; 10737 const int kRestrictedAlternatePort = 80;
10732 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10738 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10733 kRestrictedAlternatePort); 10739 kRestrictedAlternatePort);
10734 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10740 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10735 http_server_properties->SetAlternativeService( 10741 http_server_properties->SetAlternativeService(
10736 url::SchemeHostPort(unrestricted_port_request.url), alternative_service, 10742 url::SchemeHostPort(unrestricted_port_request.url), alternative_service,
10737 expiration); 10743 expiration, HttpNetworkSession::Params().quic_supported_versions);
10738 10744
10739 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10745 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10740 TestCompletionCallback callback; 10746 TestCompletionCallback callback;
10741 10747
10742 int rv = trans.Start(&unrestricted_port_request, callback.callback(), 10748 int rv = trans.Start(&unrestricted_port_request, callback.callback(),
10743 NetLogWithSource()); 10749 NetLogWithSource());
10744 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10750 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10745 // Valid change to restricted port should pass. 10751 // Valid change to restricted port should pass.
10746 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10752 EXPECT_THAT(callback.WaitForResult(), IsOk());
10747 } 10753 }
(...skipping 28 matching lines...) Expand all
10776 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10782 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10777 10783
10778 HttpServerProperties* http_server_properties = 10784 HttpServerProperties* http_server_properties =
10779 session->http_server_properties(); 10785 session->http_server_properties();
10780 const int kUnrestrictedAlternatePort = 1025; 10786 const int kUnrestrictedAlternatePort = 1025;
10781 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10787 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10782 kUnrestrictedAlternatePort); 10788 kUnrestrictedAlternatePort);
10783 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10789 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10784 http_server_properties->SetAlternativeService( 10790 http_server_properties->SetAlternativeService(
10785 url::SchemeHostPort(unrestricted_port_request.url), alternative_service, 10791 url::SchemeHostPort(unrestricted_port_request.url), alternative_service,
10786 expiration); 10792 expiration, HttpNetworkSession::Params().quic_supported_versions);
10787 10793
10788 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10794 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10789 TestCompletionCallback callback; 10795 TestCompletionCallback callback;
10790 10796
10791 int rv = trans.Start(&unrestricted_port_request, callback.callback(), 10797 int rv = trans.Start(&unrestricted_port_request, callback.callback(),
10792 NetLogWithSource()); 10798 NetLogWithSource());
10793 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10799 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10794 // Valid change to an unrestricted port should pass. 10800 // Valid change to an unrestricted port should pass.
10795 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10801 EXPECT_THAT(callback.WaitForResult(), IsOk());
10796 } 10802 }
(...skipping 19 matching lines...) Expand all
10816 10822
10817 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10823 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10818 10824
10819 HttpServerProperties* http_server_properties = 10825 HttpServerProperties* http_server_properties =
10820 session->http_server_properties(); 10826 session->http_server_properties();
10821 const int kUnsafePort = 7; 10827 const int kUnsafePort = 7;
10822 AlternativeService alternative_service(kProtoHTTP2, "www.example.org", 10828 AlternativeService alternative_service(kProtoHTTP2, "www.example.org",
10823 kUnsafePort); 10829 kUnsafePort);
10824 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10830 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10825 http_server_properties->SetAlternativeService( 10831 http_server_properties->SetAlternativeService(
10826 url::SchemeHostPort(request.url), alternative_service, expiration); 10832 url::SchemeHostPort(request.url), alternative_service, expiration,
10833 HttpNetworkSession::Params().quic_supported_versions);
10827 10834
10828 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10835 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10829 TestCompletionCallback callback; 10836 TestCompletionCallback callback;
10830 10837
10831 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 10838 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
10832 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 10839 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
10833 // The HTTP request should succeed. 10840 // The HTTP request should succeed.
10834 EXPECT_THAT(callback.WaitForResult(), IsOk()); 10841 EXPECT_THAT(callback.WaitForResult(), IsOk());
10835 10842
10836 const HttpResponseInfo* response = trans.GetResponseInfo(); 10843 const HttpResponseInfo* response = trans.GetResponseInfo();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
11175 11182
11176 // Configure alternative service with a hostname that is not bypassed by the 11183 // Configure alternative service with a hostname that is not bypassed by the
11177 // proxy. 11184 // proxy.
11178 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11185 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11179 HttpServerProperties* http_server_properties = 11186 HttpServerProperties* http_server_properties =
11180 session->http_server_properties(); 11187 session->http_server_properties();
11181 url::SchemeHostPort server("https", "www.example.org", 443); 11188 url::SchemeHostPort server("https", "www.example.org", 443);
11182 HostPortPair alternative("www.example.com", 443); 11189 HostPortPair alternative("www.example.com", 443);
11183 AlternativeService alternative_service(kProtoHTTP2, alternative); 11190 AlternativeService alternative_service(kProtoHTTP2, alternative);
11184 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 11191 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
11185 http_server_properties->SetAlternativeService(server, alternative_service, 11192 http_server_properties->SetAlternativeService(
11186 expiration); 11193 server, alternative_service, expiration,
11194 HttpNetworkSession::Params().quic_supported_versions);
11187 11195
11188 // Non-alternative job should hang. 11196 // Non-alternative job should hang.
11189 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); 11197 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
11190 StaticSocketDataProvider hanging_alternate_protocol_socket(nullptr, 0, 11198 StaticSocketDataProvider hanging_alternate_protocol_socket(nullptr, 0,
11191 nullptr, 0); 11199 nullptr, 0);
11192 hanging_alternate_protocol_socket.set_connect_data(never_finishing_connect); 11200 hanging_alternate_protocol_socket.set_connect_data(never_finishing_connect);
11193 session_deps_.socket_factory->AddSocketDataProvider( 11201 session_deps_.socket_factory->AddSocketDataProvider(
11194 &hanging_alternate_protocol_socket); 11202 &hanging_alternate_protocol_socket);
11195 11203
11196 AddSSLSocketData(); 11204 AddSSLSocketData();
(...skipping 2862 matching lines...) Expand 10 before | Expand all | Expand 10 after
14059 StaticSocketDataProvider data_refused; 14067 StaticSocketDataProvider data_refused;
14060 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 14068 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
14061 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 14069 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
14062 14070
14063 // Set up alternative service for server. 14071 // Set up alternative service for server.
14064 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14072 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14065 HttpServerProperties* http_server_properties = 14073 HttpServerProperties* http_server_properties =
14066 session->http_server_properties(); 14074 session->http_server_properties();
14067 AlternativeService alternative_service(kProtoHTTP2, alternative); 14075 AlternativeService alternative_service(kProtoHTTP2, alternative);
14068 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 14076 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
14069 http_server_properties->SetAlternativeService(server, alternative_service, 14077 http_server_properties->SetAlternativeService(
14070 expiration); 14078 server, alternative_service, expiration,
14079 HttpNetworkSession::Params().quic_supported_versions);
14071 14080
14072 HttpRequestInfo request; 14081 HttpRequestInfo request;
14073 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 14082 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
14074 request.method = "GET"; 14083 request.method = "GET";
14075 request.url = GURL("https://www.example.org:443"); 14084 request.url = GURL("https://www.example.org:443");
14076 TestCompletionCallback callback; 14085 TestCompletionCallback callback;
14077 14086
14078 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is 14087 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is
14079 // negotiated, the alternate Job should fail with ERR_ALPN_NEGOTIATION_FAILED. 14088 // negotiated, the alternate Job should fail with ERR_ALPN_NEGOTIATION_FAILED.
14080 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 14089 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
14126 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), 14135 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads),
14127 http_writes, arraysize(http_writes)); 14136 http_writes, arraysize(http_writes));
14128 session_deps_.socket_factory->AddSocketDataProvider(&http_data); 14137 session_deps_.socket_factory->AddSocketDataProvider(&http_data);
14129 14138
14130 // Set up alternative service for server. 14139 // Set up alternative service for server.
14131 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14140 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14132 HttpServerProperties* http_server_properties = 14141 HttpServerProperties* http_server_properties =
14133 session->http_server_properties(); 14142 session->http_server_properties();
14134 AlternativeService alternative_service(kProtoHTTP2, alternative); 14143 AlternativeService alternative_service(kProtoHTTP2, alternative);
14135 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 14144 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
14136 http_server_properties->SetAlternativeService(server, alternative_service, 14145 http_server_properties->SetAlternativeService(
14137 expiration); 14146 server, alternative_service, expiration,
14147 HttpNetworkSession::Params().quic_supported_versions);
14138 14148
14139 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 14149 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
14140 HttpRequestInfo request1; 14150 HttpRequestInfo request1;
14141 request1.method = "GET"; 14151 request1.method = "GET";
14142 request1.url = GURL("https://www.example.org:443"); 14152 request1.url = GURL("https://www.example.org:443");
14143 request1.load_flags = 0; 14153 request1.load_flags = 0;
14144 TestCompletionCallback callback1; 14154 TestCompletionCallback callback1;
14145 14155
14146 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource()); 14156 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource());
14147 rv = callback1.GetResult(rv); 14157 rv = callback1.GetResult(rv);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
14233 StaticSocketDataProvider data_refused; 14243 StaticSocketDataProvider data_refused;
14234 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 14244 data_refused.set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
14235 session_deps_.socket_factory->AddSocketDataProvider(&data_refused); 14245 session_deps_.socket_factory->AddSocketDataProvider(&data_refused);
14236 14246
14237 // Set up alternative service for server. 14247 // Set up alternative service for server.
14238 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14248 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14239 HttpServerProperties* http_server_properties = 14249 HttpServerProperties* http_server_properties =
14240 session->http_server_properties(); 14250 session->http_server_properties();
14241 AlternativeService alternative_service(kProtoHTTP2, alternative); 14251 AlternativeService alternative_service(kProtoHTTP2, alternative);
14242 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 14252 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
14243 http_server_properties->SetAlternativeService(server, alternative_service, 14253 http_server_properties->SetAlternativeService(
14244 expiration); 14254 server, alternative_service, expiration,
14255 HttpNetworkSession::Params().quic_supported_versions);
14245 14256
14246 // First transaction to alternative to open an HTTP/1.1 socket. 14257 // First transaction to alternative to open an HTTP/1.1 socket.
14247 HttpRequestInfo request1; 14258 HttpRequestInfo request1;
14248 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 14259 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
14249 request1.method = "GET"; 14260 request1.method = "GET";
14250 request1.url = GURL(alternative_url); 14261 request1.url = GURL(alternative_url);
14251 request1.load_flags = 0; 14262 request1.load_flags = 0;
14252 TestCompletionCallback callback1; 14263 TestCompletionCallback callback1;
14253 14264
14254 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource()); 14265 int rv = trans1.Start(&request1, callback1.callback(), NetLogWithSource());
(...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after
16912 16923
16913 TestCompletionCallback callback; 16924 TestCompletionCallback callback;
16914 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 16925 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
16915 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); 16926 int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
16916 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 16927 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
16917 16928
16918 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_NO_SUPPORTED_PROXIES)); 16929 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_NO_SUPPORTED_PROXIES));
16919 } 16930 }
16920 16931
16921 } // namespace net 16932 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698