| 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 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13363 | 13362 |
| 13364 session_deps_.parse_alternative_services = true; | 13363 session_deps_.parse_alternative_services = true; |
| 13365 session_deps_.enable_alternative_service_with_different_host = true; | 13364 session_deps_.enable_alternative_service_with_different_host = true; |
| 13366 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13365 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13367 base::WeakPtr<HttpServerProperties> http_server_properties = | 13366 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13368 session->http_server_properties(); | 13367 session->http_server_properties(); |
| 13369 AlternativeService alternative_service( | 13368 AlternativeService alternative_service( |
| 13370 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13369 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13371 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13370 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13372 http_server_properties->SetAlternativeService(origin, alternative_service, | 13371 http_server_properties->SetAlternativeService(origin, alternative_service, |
| 13373 1.0, expiration); | 13372 expiration); |
| 13374 | 13373 |
| 13375 // First request to alternative. | 13374 // First request to alternative. |
| 13376 if (pooling) { | 13375 if (pooling) { |
| 13377 scoped_ptr<HttpTransaction> trans0( | 13376 scoped_ptr<HttpTransaction> trans0( |
| 13378 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13377 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13379 HttpRequestInfo request0; | 13378 HttpRequestInfo request0; |
| 13380 request0.method = "GET"; | 13379 request0.method = "GET"; |
| 13381 request0.url = GURL(url0); | 13380 request0.url = GURL(url0); |
| 13382 request0.load_flags = 0; | 13381 request0.load_flags = 0; |
| 13383 TestCompletionCallback callback0; | 13382 TestCompletionCallback callback0; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13468 // Set up alternative service for origin. | 13467 // Set up alternative service for origin. |
| 13469 session_deps_.parse_alternative_services = true; | 13468 session_deps_.parse_alternative_services = true; |
| 13470 session_deps_.enable_alternative_service_with_different_host = true; | 13469 session_deps_.enable_alternative_service_with_different_host = true; |
| 13471 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13470 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13472 base::WeakPtr<HttpServerProperties> http_server_properties = | 13471 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13473 session->http_server_properties(); | 13472 session->http_server_properties(); |
| 13474 AlternativeService alternative_service( | 13473 AlternativeService alternative_service( |
| 13475 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13474 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13476 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13475 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13477 http_server_properties->SetAlternativeService(origin, alternative_service, | 13476 http_server_properties->SetAlternativeService(origin, alternative_service, |
| 13478 1.0, expiration); | 13477 expiration); |
| 13479 | 13478 |
| 13480 scoped_ptr<HttpTransaction> trans( | 13479 scoped_ptr<HttpTransaction> trans( |
| 13481 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13480 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13482 HttpRequestInfo request; | 13481 HttpRequestInfo request; |
| 13483 request.method = "GET"; | 13482 request.method = "GET"; |
| 13484 request.url = GURL("https://origin.example.org:443"); | 13483 request.url = GURL("https://origin.example.org:443"); |
| 13485 request.load_flags = 0; | 13484 request.load_flags = 0; |
| 13486 TestCompletionCallback callback; | 13485 TestCompletionCallback callback; |
| 13487 | 13486 |
| 13488 // HTTP/2 (or SPDY) is required for alternative service, if HTTP/1.1 is | 13487 // 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... |
| 13542 // Set up alternative service for origin. | 13541 // Set up alternative service for origin. |
| 13543 session_deps_.parse_alternative_services = true; | 13542 session_deps_.parse_alternative_services = true; |
| 13544 session_deps_.enable_alternative_service_with_different_host = true; | 13543 session_deps_.enable_alternative_service_with_different_host = true; |
| 13545 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13544 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13546 base::WeakPtr<HttpServerProperties> http_server_properties = | 13545 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13547 session->http_server_properties(); | 13546 session->http_server_properties(); |
| 13548 AlternativeService alternative_service( | 13547 AlternativeService alternative_service( |
| 13549 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13548 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13550 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13549 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13551 http_server_properties->SetAlternativeService(origin, alternative_service, | 13550 http_server_properties->SetAlternativeService(origin, alternative_service, |
| 13552 1.0, expiration); | 13551 expiration); |
| 13553 | 13552 |
| 13554 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); | 13553 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, session.get()); |
| 13555 HttpRequestInfo request1; | 13554 HttpRequestInfo request1; |
| 13556 request1.method = "GET"; | 13555 request1.method = "GET"; |
| 13557 request1.url = GURL("https://origin.example.org:443"); | 13556 request1.url = GURL("https://origin.example.org:443"); |
| 13558 request1.load_flags = 0; | 13557 request1.load_flags = 0; |
| 13559 TestCompletionCallback callback1; | 13558 TestCompletionCallback callback1; |
| 13560 | 13559 |
| 13561 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); | 13560 int rv = trans1.Start(&request1, callback1.callback(), BoundNetLog()); |
| 13562 rv = callback1.GetResult(rv); | 13561 rv = callback1.GetResult(rv); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13652 // Set up alternative service for origin. | 13651 // Set up alternative service for origin. |
| 13653 session_deps_.parse_alternative_services = true; | 13652 session_deps_.parse_alternative_services = true; |
| 13654 session_deps_.enable_alternative_service_with_different_host = false; | 13653 session_deps_.enable_alternative_service_with_different_host = false; |
| 13655 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 13654 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 13656 base::WeakPtr<HttpServerProperties> http_server_properties = | 13655 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 13657 session->http_server_properties(); | 13656 session->http_server_properties(); |
| 13658 AlternativeService alternative_service( | 13657 AlternativeService alternative_service( |
| 13659 AlternateProtocolFromNextProto(GetProtocol()), alternative); | 13658 AlternateProtocolFromNextProto(GetProtocol()), alternative); |
| 13660 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 13659 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 13661 http_server_properties->SetAlternativeService(origin, alternative_service, | 13660 http_server_properties->SetAlternativeService(origin, alternative_service, |
| 13662 1.0, expiration); | 13661 expiration); |
| 13663 | 13662 |
| 13664 // First transaction to alternative to open an HTTP/1.1 socket. | 13663 // First transaction to alternative to open an HTTP/1.1 socket. |
| 13665 scoped_ptr<HttpTransaction> trans1( | 13664 scoped_ptr<HttpTransaction> trans1( |
| 13666 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13665 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 13667 HttpRequestInfo request1; | 13666 HttpRequestInfo request1; |
| 13668 request1.method = "GET"; | 13667 request1.method = "GET"; |
| 13669 request1.url = GURL(alternative_url); | 13668 request1.url = GURL(alternative_url); |
| 13670 request1.load_flags = 0; | 13669 request1.load_flags = 0; |
| 13671 TestCompletionCallback callback1; | 13670 TestCompletionCallback callback1; |
| 13672 | 13671 |
| (...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15959 base::MessageLoop::current()->RunUntilIdle(); | 15958 base::MessageLoop::current()->RunUntilIdle(); |
| 15960 | 15959 |
| 15961 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15960 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15962 HttpRequestHeaders headers; | 15961 HttpRequestHeaders headers; |
| 15963 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15962 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15964 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15963 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15965 } | 15964 } |
| 15966 #endif // !defined(OS_IOS) | 15965 #endif // !defined(OS_IOS) |
| 15967 | 15966 |
| 15968 } // namespace net | 15967 } // namespace net |
| OLD | NEW |