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

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

Issue 1802893002: Revert of Remove support for Alt-Svc/Alternate Protocol Probability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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_network_session.cc ('k') | net/http/http_server_properties.h » ('j') | no next file with comments »
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 #include <limits> 10 #include <limits>
(...skipping 8791 matching lines...) Expand 10 before | Expand all | Expand 10 after
8802 NextProto next_proto, 8802 NextProto next_proto,
8803 SpdySessionDependencies* session_deps_) { 8803 SpdySessionDependencies* session_deps_) {
8804 scoped_ptr<HttpNetworkSession> session(CreateSession(session_deps_)); 8804 scoped_ptr<HttpNetworkSession> session(CreateSession(session_deps_));
8805 8805
8806 base::WeakPtr<HttpServerProperties> http_server_properties = 8806 base::WeakPtr<HttpServerProperties> http_server_properties =
8807 session->http_server_properties(); 8807 session->http_server_properties();
8808 AlternativeService alternative_service( 8808 AlternativeService alternative_service(
8809 AlternateProtocolFromNextProto(next_proto), "", 443); 8809 AlternateProtocolFromNextProto(next_proto), "", 443);
8810 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 8810 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
8811 http_server_properties->SetAlternativeService( 8811 http_server_properties->SetAlternativeService(
8812 HostPortPair("host.with.alternate", 80), alternative_service, expiration); 8812 HostPortPair("host.with.alternate", 80), alternative_service, 1.0,
8813 expiration);
8813 8814
8814 return session; 8815 return session;
8815 } 8816 }
8816 8817
8817 int GroupNameTransactionHelper(const std::string& url, 8818 int GroupNameTransactionHelper(const std::string& url,
8818 HttpNetworkSession* session) { 8819 HttpNetworkSession* session) {
8819 HttpRequestInfo request; 8820 HttpRequestInfo request;
8820 request.method = "GET"; 8821 request.method = "GET";
8821 request.url = GURL(url); 8822 request.url = GURL(url);
8822 request.load_flags = 0; 8823 request.load_flags = 0;
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
9729 session_deps_.parse_alternative_services = true; 9730 session_deps_.parse_alternative_services = true;
9730 session_deps_.enable_alternative_service_with_different_host = false; 9731 session_deps_.enable_alternative_service_with_different_host = false;
9731 9732
9732 // Set an alternative service for origin. 9733 // Set an alternative service for origin.
9733 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9734 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9734 HttpServerProperties& http_server_properties = 9735 HttpServerProperties& http_server_properties =
9735 *session->http_server_properties(); 9736 *session->http_server_properties();
9736 HostPortPair http_host_port_pair("www.example.org", 80); 9737 HostPortPair http_host_port_pair("www.example.org", 80);
9737 AlternativeService alternative_service(QUIC, "", 80); 9738 AlternativeService alternative_service(QUIC, "", 80);
9738 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 9739 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
9739 http_server_properties.SetAlternativeService(http_host_port_pair, 9740 http_server_properties.SetAlternativeService(
9740 alternative_service, expiration); 9741 http_host_port_pair, alternative_service, 1.0, expiration);
9741 AlternativeServiceVector alternative_service_vector = 9742 AlternativeServiceVector alternative_service_vector =
9742 http_server_properties.GetAlternativeServices(http_host_port_pair); 9743 http_server_properties.GetAlternativeServices(http_host_port_pair);
9743 EXPECT_EQ(1u, alternative_service_vector.size()); 9744 EXPECT_EQ(1u, alternative_service_vector.size());
9744 9745
9745 // Send a clear header. 9746 // Send a clear header.
9746 MockRead data_reads[] = { 9747 MockRead data_reads[] = {
9747 MockRead("HTTP/1.1 200 OK\r\n"), 9748 MockRead("HTTP/1.1 200 OK\r\n"),
9748 MockRead("Alt-Svc: clear\r\n"), 9749 MockRead("Alt-Svc: clear\r\n"),
9749 MockRead("\r\n"), 9750 MockRead("\r\n"),
9750 MockRead("hello world"), 9751 MockRead("hello world"),
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
9991 9992
9992 TestCompletionCallback callback; 9993 TestCompletionCallback callback;
9993 9994
9994 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 9995 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
9995 9996
9996 HostPortPair http_host_port_pair("www.example.org", 80); 9997 HostPortPair http_host_port_pair("www.example.org", 80);
9997 HttpServerProperties& http_server_properties = 9998 HttpServerProperties& http_server_properties =
9998 *session->http_server_properties(); 9999 *session->http_server_properties();
9999 AlternativeService alternative_service(QUIC, "", 80); 10000 AlternativeService alternative_service(QUIC, "", 80);
10000 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10001 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10001 http_server_properties.SetAlternativeService(http_host_port_pair, 10002 http_server_properties.SetAlternativeService(
10002 alternative_service, expiration); 10003 http_host_port_pair, alternative_service, 1.0, expiration);
10003 10004
10004 AlternativeServiceVector alternative_service_vector = 10005 AlternativeServiceVector alternative_service_vector =
10005 http_server_properties.GetAlternativeServices(http_host_port_pair); 10006 http_server_properties.GetAlternativeServices(http_host_port_pair);
10006 ASSERT_EQ(1u, alternative_service_vector.size()); 10007 ASSERT_EQ(1u, alternative_service_vector.size());
10007 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); 10008 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
10008 10009
10009 scoped_ptr<HttpTransaction> trans( 10010 scoped_ptr<HttpTransaction> trans(
10010 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10011 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10011 10012
10012 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10013 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
10122 10123
10123 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_); 10124 scoped_ptr<HttpNetworkSession> session = CreateSession(&session_deps_);
10124 10125
10125 base::WeakPtr<HttpServerProperties> http_server_properties = 10126 base::WeakPtr<HttpServerProperties> http_server_properties =
10126 session->http_server_properties(); 10127 session->http_server_properties();
10127 AlternativeService alternative_service( 10128 AlternativeService alternative_service(
10128 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org", 10129 AlternateProtocolFromNextProto(GetProtocol()), "different.example.org",
10129 80); 10130 80);
10130 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10131 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10131 http_server_properties->SetAlternativeService( 10132 http_server_properties->SetAlternativeService(
10132 HostPortPair::FromURL(request.url), alternative_service, expiration); 10133 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration);
10133 10134
10134 scoped_ptr<HttpTransaction> trans( 10135 scoped_ptr<HttpTransaction> trans(
10135 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10136 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10136 TestCompletionCallback callback; 10137 TestCompletionCallback callback;
10137 10138
10138 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10139 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10139 // The connetion to origin was refused, and the alternative service should not 10140 // The connetion to origin was refused, and the alternative service should not
10140 // be used (even though mock data are there), therefore the request should 10141 // be used (even though mock data are there), therefore the request should
10141 // fail. 10142 // fail.
10142 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv)); 10143 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.GetResult(rv));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
10176 10177
10177 // Set up a QUIC alternative service for origin. 10178 // Set up a QUIC alternative service for origin.
10178 session_deps_.parse_alternative_services = true; 10179 session_deps_.parse_alternative_services = true;
10179 session_deps_.enable_alternative_service_with_different_host = false; 10180 session_deps_.enable_alternative_service_with_different_host = false;
10180 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10181 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10181 base::WeakPtr<HttpServerProperties> http_server_properties = 10182 base::WeakPtr<HttpServerProperties> http_server_properties =
10182 session->http_server_properties(); 10183 session->http_server_properties();
10183 AlternativeService alternative_service(QUIC, alternative); 10184 AlternativeService alternative_service(QUIC, alternative);
10184 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10185 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10185 http_server_properties->SetAlternativeService(origin, alternative_service, 10186 http_server_properties->SetAlternativeService(origin, alternative_service,
10186 expiration); 10187 1.0, expiration);
10187 // Mark the QUIC alternative service as broken. 10188 // Mark the QUIC alternative service as broken.
10188 http_server_properties->MarkAlternativeServiceBroken(alternative_service); 10189 http_server_properties->MarkAlternativeServiceBroken(alternative_service);
10189 10190
10190 scoped_ptr<HttpTransaction> trans( 10191 scoped_ptr<HttpTransaction> trans(
10191 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10192 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10192 HttpRequestInfo request; 10193 HttpRequestInfo request;
10193 request.method = "GET"; 10194 request.method = "GET";
10194 request.url = GURL(origin_url); 10195 request.url = GURL(origin_url);
10195 request.load_flags = 0; 10196 request.load_flags = 0;
10196 TestCompletionCallback callback; 10197 TestCompletionCallback callback;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
10240 session_deps_.enable_alternative_service_with_different_host = true; 10241 session_deps_.enable_alternative_service_with_different_host = true;
10241 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10242 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10242 base::WeakPtr<HttpServerProperties> http_server_properties = 10243 base::WeakPtr<HttpServerProperties> http_server_properties =
10243 session->http_server_properties(); 10244 session->http_server_properties();
10244 10245
10245 // Set up two QUIC alternative services for origin. 10246 // Set up two QUIC alternative services for origin.
10246 AlternativeServiceInfoVector alternative_service_info_vector; 10247 AlternativeServiceInfoVector alternative_service_info_vector;
10247 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10248 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10248 10249
10249 AlternativeService alternative_service1(QUIC, alternative1); 10250 AlternativeService alternative_service1(QUIC, alternative1);
10250 AlternativeServiceInfo alternative_service_info1(alternative_service1, 10251 AlternativeServiceInfo alternative_service_info1(alternative_service1, 1.0,
10251 expiration); 10252 expiration);
10252 alternative_service_info_vector.push_back(alternative_service_info1); 10253 alternative_service_info_vector.push_back(alternative_service_info1);
10253 AlternativeService alternative_service2(QUIC, alternative2); 10254 AlternativeService alternative_service2(QUIC, alternative2);
10254 AlternativeServiceInfo alternative_service_info2(alternative_service2, 10255 AlternativeServiceInfo alternative_service_info2(alternative_service2, 1.0,
10255 expiration); 10256 expiration);
10256 alternative_service_info_vector.push_back(alternative_service_info2); 10257 alternative_service_info_vector.push_back(alternative_service_info2);
10257 10258
10258 http_server_properties->SetAlternativeServices( 10259 http_server_properties->SetAlternativeServices(
10259 origin, alternative_service_info_vector); 10260 origin, alternative_service_info_vector);
10260 10261
10261 // Mark one of the QUIC alternative service as broken. 10262 // Mark one of the QUIC alternative service as broken.
10262 http_server_properties->MarkAlternativeServiceBroken(alternative_service1); 10263 http_server_properties->MarkAlternativeServiceBroken(alternative_service1);
10263 10264
10264 const AlternativeServiceVector alternative_service_vector = 10265 const AlternativeServiceVector alternative_service_vector =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
10308 base::WeakPtr<HttpServerProperties> http_server_properties = 10309 base::WeakPtr<HttpServerProperties> http_server_properties =
10309 session->http_server_properties(); 10310 session->http_server_properties();
10310 const HostPortPair host_port_pair = HostPortPair::FromURL(request.url); 10311 const HostPortPair host_port_pair = HostPortPair::FromURL(request.url);
10311 // Port must be < 1024, or the header will be ignored (since initial port was 10312 // Port must be < 1024, or the header will be ignored (since initial port was
10312 // port 80 (another restricted port). 10313 // port 80 (another restricted port).
10313 const AlternativeService alternative_service( 10314 const AlternativeService alternative_service(
10314 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10315 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10315 666); // Port is ignored by MockConnect anyway. 10316 666); // Port is ignored by MockConnect anyway.
10316 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10317 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10317 http_server_properties->SetAlternativeService( 10318 http_server_properties->SetAlternativeService(
10318 host_port_pair, alternative_service, expiration); 10319 host_port_pair, alternative_service, 1.0, expiration);
10319 10320
10320 scoped_ptr<HttpTransaction> trans( 10321 scoped_ptr<HttpTransaction> trans(
10321 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10322 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10322 TestCompletionCallback callback; 10323 TestCompletionCallback callback;
10323 10324
10324 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10325 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10325 EXPECT_EQ(ERR_IO_PENDING, rv); 10326 EXPECT_EQ(ERR_IO_PENDING, rv);
10326 EXPECT_EQ(OK, callback.WaitForResult()); 10327 EXPECT_EQ(OK, callback.WaitForResult());
10327 10328
10328 const HttpResponseInfo* response = trans->GetResponseInfo(); 10329 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
10374 10375
10375 base::WeakPtr<HttpServerProperties> http_server_properties = 10376 base::WeakPtr<HttpServerProperties> http_server_properties =
10376 session->http_server_properties(); 10377 session->http_server_properties();
10377 const int kUnrestrictedAlternatePort = 1024; 10378 const int kUnrestrictedAlternatePort = 1024;
10378 AlternativeService alternative_service( 10379 AlternativeService alternative_service(
10379 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10380 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10380 kUnrestrictedAlternatePort); 10381 kUnrestrictedAlternatePort);
10381 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10382 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10382 http_server_properties->SetAlternativeService( 10383 http_server_properties->SetAlternativeService(
10383 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 10384 HostPortPair::FromURL(restricted_port_request.url), alternative_service,
10384 expiration); 10385 1.0, expiration);
10385 10386
10386 scoped_ptr<HttpTransaction> trans( 10387 scoped_ptr<HttpTransaction> trans(
10387 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10388 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10388 TestCompletionCallback callback; 10389 TestCompletionCallback callback;
10389 10390
10390 int rv = trans->Start( 10391 int rv = trans->Start(
10391 &restricted_port_request, 10392 &restricted_port_request,
10392 callback.callback(), BoundNetLog()); 10393 callback.callback(), BoundNetLog());
10393 EXPECT_EQ(ERR_IO_PENDING, rv); 10394 EXPECT_EQ(ERR_IO_PENDING, rv);
10394 // Invalid change to unrestricted port should fail. 10395 // Invalid change to unrestricted port should fail.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
10427 10428
10428 base::WeakPtr<HttpServerProperties> http_server_properties = 10429 base::WeakPtr<HttpServerProperties> http_server_properties =
10429 session->http_server_properties(); 10430 session->http_server_properties();
10430 const int kUnrestrictedAlternatePort = 1024; 10431 const int kUnrestrictedAlternatePort = 1024;
10431 AlternativeService alternative_service( 10432 AlternativeService alternative_service(
10432 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10433 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10433 kUnrestrictedAlternatePort); 10434 kUnrestrictedAlternatePort);
10434 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10435 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10435 http_server_properties->SetAlternativeService( 10436 http_server_properties->SetAlternativeService(
10436 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 10437 HostPortPair::FromURL(restricted_port_request.url), alternative_service,
10437 expiration); 10438 1.0, expiration);
10438 10439
10439 scoped_ptr<HttpTransaction> trans( 10440 scoped_ptr<HttpTransaction> trans(
10440 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10441 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10441 TestCompletionCallback callback; 10442 TestCompletionCallback callback;
10442 10443
10443 EXPECT_EQ(ERR_IO_PENDING, trans->Start( 10444 EXPECT_EQ(ERR_IO_PENDING, trans->Start(
10444 &restricted_port_request, 10445 &restricted_port_request,
10445 callback.callback(), BoundNetLog())); 10446 callback.callback(), BoundNetLog()));
10446 // Change to unrestricted port should succeed. 10447 // Change to unrestricted port should succeed.
10447 EXPECT_EQ(OK, callback.WaitForResult()); 10448 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10479 10480
10480 base::WeakPtr<HttpServerProperties> http_server_properties = 10481 base::WeakPtr<HttpServerProperties> http_server_properties =
10481 session->http_server_properties(); 10482 session->http_server_properties();
10482 const int kRestrictedAlternatePort = 80; 10483 const int kRestrictedAlternatePort = 80;
10483 AlternativeService alternative_service( 10484 AlternativeService alternative_service(
10484 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10485 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10485 kRestrictedAlternatePort); 10486 kRestrictedAlternatePort);
10486 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10487 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10487 http_server_properties->SetAlternativeService( 10488 http_server_properties->SetAlternativeService(
10488 HostPortPair::FromURL(restricted_port_request.url), alternative_service, 10489 HostPortPair::FromURL(restricted_port_request.url), alternative_service,
10489 expiration); 10490 1.0, expiration);
10490 10491
10491 scoped_ptr<HttpTransaction> trans( 10492 scoped_ptr<HttpTransaction> trans(
10492 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10493 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10493 TestCompletionCallback callback; 10494 TestCompletionCallback callback;
10494 10495
10495 int rv = trans->Start( 10496 int rv = trans->Start(
10496 &restricted_port_request, 10497 &restricted_port_request,
10497 callback.callback(), BoundNetLog()); 10498 callback.callback(), BoundNetLog());
10498 EXPECT_EQ(ERR_IO_PENDING, rv); 10499 EXPECT_EQ(ERR_IO_PENDING, rv);
10499 // Valid change to restricted port should pass. 10500 // Valid change to restricted port should pass.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
10532 10533
10533 base::WeakPtr<HttpServerProperties> http_server_properties = 10534 base::WeakPtr<HttpServerProperties> http_server_properties =
10534 session->http_server_properties(); 10535 session->http_server_properties();
10535 const int kRestrictedAlternatePort = 80; 10536 const int kRestrictedAlternatePort = 80;
10536 AlternativeService alternative_service( 10537 AlternativeService alternative_service(
10537 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10538 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10538 kRestrictedAlternatePort); 10539 kRestrictedAlternatePort);
10539 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10540 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10540 http_server_properties->SetAlternativeService( 10541 http_server_properties->SetAlternativeService(
10541 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, 10542 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service,
10542 expiration); 10543 1.0, expiration);
10543 10544
10544 scoped_ptr<HttpTransaction> trans( 10545 scoped_ptr<HttpTransaction> trans(
10545 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10546 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10546 TestCompletionCallback callback; 10547 TestCompletionCallback callback;
10547 10548
10548 int rv = trans->Start( 10549 int rv = trans->Start(
10549 &unrestricted_port_request, callback.callback(), BoundNetLog()); 10550 &unrestricted_port_request, callback.callback(), BoundNetLog());
10550 EXPECT_EQ(ERR_IO_PENDING, rv); 10551 EXPECT_EQ(ERR_IO_PENDING, rv);
10551 // Valid change to restricted port should pass. 10552 // Valid change to restricted port should pass.
10552 EXPECT_EQ(OK, callback.WaitForResult()); 10553 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10584 10585
10585 base::WeakPtr<HttpServerProperties> http_server_properties = 10586 base::WeakPtr<HttpServerProperties> http_server_properties =
10586 session->http_server_properties(); 10587 session->http_server_properties();
10587 const int kUnrestrictedAlternatePort = 1025; 10588 const int kUnrestrictedAlternatePort = 1025;
10588 AlternativeService alternative_service( 10589 AlternativeService alternative_service(
10589 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10590 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10590 kUnrestrictedAlternatePort); 10591 kUnrestrictedAlternatePort);
10591 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10592 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10592 http_server_properties->SetAlternativeService( 10593 http_server_properties->SetAlternativeService(
10593 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service, 10594 HostPortPair::FromURL(unrestricted_port_request.url), alternative_service,
10594 expiration); 10595 1.0, expiration);
10595 10596
10596 scoped_ptr<HttpTransaction> trans( 10597 scoped_ptr<HttpTransaction> trans(
10597 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10598 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10598 TestCompletionCallback callback; 10599 TestCompletionCallback callback;
10599 10600
10600 int rv = trans->Start( 10601 int rv = trans->Start(
10601 &unrestricted_port_request, callback.callback(), BoundNetLog()); 10602 &unrestricted_port_request, callback.callback(), BoundNetLog());
10602 EXPECT_EQ(ERR_IO_PENDING, rv); 10603 EXPECT_EQ(ERR_IO_PENDING, rv);
10603 // Valid change to an unrestricted port should pass. 10604 // Valid change to an unrestricted port should pass.
10604 EXPECT_EQ(OK, callback.WaitForResult()); 10605 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 25 matching lines...) Expand all
10630 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10631 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10631 10632
10632 base::WeakPtr<HttpServerProperties> http_server_properties = 10633 base::WeakPtr<HttpServerProperties> http_server_properties =
10633 session->http_server_properties(); 10634 session->http_server_properties();
10634 const int kUnsafePort = 7; 10635 const int kUnsafePort = 7;
10635 AlternativeService alternative_service( 10636 AlternativeService alternative_service(
10636 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org", 10637 AlternateProtocolFromNextProto(GetProtocol()), "www.example.org",
10637 kUnsafePort); 10638 kUnsafePort);
10638 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 10639 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
10639 http_server_properties->SetAlternativeService( 10640 http_server_properties->SetAlternativeService(
10640 HostPortPair::FromURL(request.url), alternative_service, expiration); 10641 HostPortPair::FromURL(request.url), alternative_service, 1.0, expiration);
10641 10642
10642 scoped_ptr<HttpTransaction> trans( 10643 scoped_ptr<HttpTransaction> trans(
10643 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10644 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10644 TestCompletionCallback callback; 10645 TestCompletionCallback callback;
10645 10646
10646 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 10647 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
10647 EXPECT_EQ(ERR_IO_PENDING, rv); 10648 EXPECT_EQ(ERR_IO_PENDING, rv);
10648 // The HTTP request should succeed. 10649 // The HTTP request should succeed.
10649 EXPECT_EQ(OK, callback.WaitForResult()); 10650 EXPECT_EQ(OK, callback.WaitForResult());
10650 10651
(...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after
13362 13363
13363 session_deps_.parse_alternative_services = true; 13364 session_deps_.parse_alternative_services = true;
13364 session_deps_.enable_alternative_service_with_different_host = true; 13365 session_deps_.enable_alternative_service_with_different_host = true;
13365 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13366 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13366 base::WeakPtr<HttpServerProperties> http_server_properties = 13367 base::WeakPtr<HttpServerProperties> http_server_properties =
13367 session->http_server_properties(); 13368 session->http_server_properties();
13368 AlternativeService alternative_service( 13369 AlternativeService alternative_service(
13369 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13370 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13370 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13371 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13371 http_server_properties->SetAlternativeService(origin, alternative_service, 13372 http_server_properties->SetAlternativeService(origin, alternative_service,
13372 expiration); 13373 1.0, expiration);
13373 13374
13374 // First request to alternative. 13375 // First request to alternative.
13375 if (pooling) { 13376 if (pooling) {
13376 scoped_ptr<HttpTransaction> trans0( 13377 scoped_ptr<HttpTransaction> trans0(
13377 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13378 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13378 HttpRequestInfo request0; 13379 HttpRequestInfo request0;
13379 request0.method = "GET"; 13380 request0.method = "GET";
13380 request0.url = GURL(url0); 13381 request0.url = GURL(url0);
13381 request0.load_flags = 0; 13382 request0.load_flags = 0;
13382 TestCompletionCallback callback0; 13383 TestCompletionCallback callback0;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
13467 // Set up alternative service for origin. 13468 // Set up alternative service for origin.
13468 session_deps_.parse_alternative_services = true; 13469 session_deps_.parse_alternative_services = true;
13469 session_deps_.enable_alternative_service_with_different_host = true; 13470 session_deps_.enable_alternative_service_with_different_host = true;
13470 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13471 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13471 base::WeakPtr<HttpServerProperties> http_server_properties = 13472 base::WeakPtr<HttpServerProperties> http_server_properties =
13472 session->http_server_properties(); 13473 session->http_server_properties();
13473 AlternativeService alternative_service( 13474 AlternativeService alternative_service(
13474 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13475 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13475 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13476 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13476 http_server_properties->SetAlternativeService(origin, alternative_service, 13477 http_server_properties->SetAlternativeService(origin, alternative_service,
13477 expiration); 13478 1.0, expiration);
13478 13479
13479 scoped_ptr<HttpTransaction> trans( 13480 scoped_ptr<HttpTransaction> trans(
13480 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13481 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13481 HttpRequestInfo request; 13482 HttpRequestInfo request;
13482 request.method = "GET"; 13483 request.method = "GET";
13483 request.url = GURL("https://origin.example.org:443"); 13484 request.url = GURL("https://origin.example.org:443");
13484 request.load_flags = 0; 13485 request.load_flags = 0;
13485 TestCompletionCallback callback; 13486 TestCompletionCallback callback;
13486 13487
13487 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is 13488 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
13541 // Set up alternative service for origin. 13542 // Set up alternative service for origin.
13542 session_deps_.parse_alternative_services = true; 13543 session_deps_.parse_alternative_services = true;
13543 session_deps_.enable_alternative_service_with_different_host = true; 13544 session_deps_.enable_alternative_service_with_different_host = true;
13544 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13545 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13545 base::WeakPtr<HttpServerProperties> http_server_properties = 13546 base::WeakPtr<HttpServerProperties> http_server_properties =
13546 session->http_server_properties(); 13547 session->http_server_properties();
13547 AlternativeService alternative_service( 13548 AlternativeService alternative_service(
13548 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13549 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13549 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13550 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13550 http_server_properties->SetAlternativeService(origin, alternative_service, 13551 http_server_properties->SetAlternativeService(origin, alternative_service,
13551 expiration); 13552 1.0, expiration);
13552 13553
13553 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); 13554 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get());
13554 HttpRequestInfo request1; 13555 HttpRequestInfo request1;
13555 request1.method = "GET"; 13556 request1.method = "GET";
13556 request1.url = GURL("https://origin.example.org:443"); 13557 request1.url = GURL("https://origin.example.org:443");
13557 request1.load_flags = 0; 13558 request1.load_flags = 0;
13558 TestCompletionCallback callback1; 13559 TestCompletionCallback callback1;
13559 13560
13560 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); 13561 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog());
13561 rv = callback1.GetResult(rv); 13562 rv = callback1.GetResult(rv);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
13651 // Set up alternative service for origin. 13652 // Set up alternative service for origin.
13652 session_deps_.parse_alternative_services = true; 13653 session_deps_.parse_alternative_services = true;
13653 session_deps_.enable_alternative_service_with_different_host = false; 13654 session_deps_.enable_alternative_service_with_different_host = false;
13654 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 13655 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
13655 base::WeakPtr<HttpServerProperties> http_server_properties = 13656 base::WeakPtr<HttpServerProperties> http_server_properties =
13656 session->http_server_properties(); 13657 session->http_server_properties();
13657 AlternativeService alternative_service( 13658 AlternativeService alternative_service(
13658 AlternateProtocolFromNextProto(GetProtocol()), alternative); 13659 AlternateProtocolFromNextProto(GetProtocol()), alternative);
13659 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 13660 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
13660 http_server_properties->SetAlternativeService(origin, alternative_service, 13661 http_server_properties->SetAlternativeService(origin, alternative_service,
13661 expiration); 13662 1.0, expiration);
13662 13663
13663 // First transaction to alternative to open an HTTP/1.1 socket. 13664 // First transaction to alternative to open an HTTP/1.1 socket.
13664 scoped_ptr<HttpTransaction> trans1( 13665 scoped_ptr<HttpTransaction> trans1(
13665 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 13666 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
13666 HttpRequestInfo request1; 13667 HttpRequestInfo request1;
13667 request1.method = "GET"; 13668 request1.method = "GET";
13668 request1.url = GURL(alternative_url); 13669 request1.url = GURL(alternative_url);
13669 request1.load_flags = 0; 13670 request1.load_flags = 0;
13670 TestCompletionCallback callback1; 13671 TestCompletionCallback callback1;
13671 13672
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after
15958 base::MessageLoop::current()->RunUntilIdle(); 15959 base::MessageLoop::current()->RunUntilIdle();
15959 15960
15960 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); 15961 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
15961 HttpRequestHeaders headers; 15962 HttpRequestHeaders headers;
15962 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); 15963 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
15963 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); 15964 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
15964 } 15965 }
15965 #endif // !defined(OS_IOS) 15966 #endif // !defined(OS_IOS)
15966 15967
15967 } // namespace net 15968 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/http/http_server_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698