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