| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_stream_request.h" | 5 #include "net/http/http_stream_request.h" | 
| 6 | 6 | 
| 7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" | 
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" | 
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" | 
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" | 
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 498         // changed. | 498         // changed. | 
| 499         authentication_url = UpgradeUrlToHttps(authentication_url); | 499         authentication_url = UpgradeUrlToHttps(authentication_url); | 
| 500       } | 500       } | 
| 501       establishing_tunnel_ = using_ssl_; | 501       establishing_tunnel_ = using_ssl_; | 
| 502       std::string user_agent; | 502       std::string user_agent; | 
| 503       request_info().extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 503       request_info().extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 
| 504                                              &user_agent); | 504                                              &user_agent); | 
| 505       scoped_refptr<SSLSocketParams> ssl_params; | 505       scoped_refptr<SSLSocketParams> ssl_params; | 
| 506       if (proxy_info()->is_https()) { | 506       if (proxy_info()->is_https()) { | 
| 507         // Set ssl_params, and unset proxy_tcp_params | 507         // Set ssl_params, and unset proxy_tcp_params | 
| 508         ssl_params = GenerateSslParams(proxy_tcp_params, NULL, NULL, | 508         ssl_params = GenerateSSLParams(proxy_tcp_params, NULL, NULL, | 
| 509                                        ProxyServer::SCHEME_DIRECT, | 509                                        ProxyServer::SCHEME_DIRECT, | 
| 510                                        proxy_host_port->host(), | 510                                        *proxy_host_port.get(), | 
| 511                                        want_spdy_over_npn); | 511                                        want_spdy_over_npn); | 
| 512         proxy_tcp_params = NULL; | 512         proxy_tcp_params = NULL; | 
| 513       } | 513       } | 
| 514 | 514 | 
| 515       http_proxy_params = | 515       http_proxy_params = | 
| 516           new HttpProxySocketParams(proxy_tcp_params, | 516           new HttpProxySocketParams(proxy_tcp_params, | 
| 517                                     ssl_params, | 517                                     ssl_params, | 
| 518                                     authentication_url, | 518                                     authentication_url, | 
| 519                                     user_agent, | 519                                     user_agent, | 
| 520                                     endpoint_, | 520                                     endpoint_, | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 537                                            socks_version == '5', | 537                                            socks_version == '5', | 
| 538                                            endpoint_, | 538                                            endpoint_, | 
| 539                                            request_info().priority, | 539                                            request_info().priority, | 
| 540                                            request_info().referrer); | 540                                            request_info().referrer); | 
| 541     } | 541     } | 
| 542   } | 542   } | 
| 543 | 543 | 
| 544   // Deal with SSL - which layers on top of any given proxy. | 544   // Deal with SSL - which layers on top of any given proxy. | 
| 545   if (using_ssl_) { | 545   if (using_ssl_) { | 
| 546     scoped_refptr<SSLSocketParams> ssl_params = | 546     scoped_refptr<SSLSocketParams> ssl_params = | 
| 547         GenerateSslParams(tcp_params, http_proxy_params, socks_params, | 547         GenerateSSLParams(tcp_params, http_proxy_params, socks_params, | 
| 548                           proxy_info()->proxy_server().scheme(), | 548                           proxy_info()->proxy_server().scheme(), | 
| 549                           request_info().url.HostNoBrackets(), | 549                           HostPortPair::FromURL(request_info().url), | 
| 550                           want_spdy_over_npn); | 550                           want_spdy_over_npn); | 
| 551     SSLClientSocketPool* ssl_pool = NULL; | 551     SSLClientSocketPool* ssl_pool = NULL; | 
| 552     if (proxy_info()->is_direct()) | 552     if (proxy_info()->is_direct()) | 
| 553       ssl_pool = session_->ssl_socket_pool(); | 553       ssl_pool = session_->ssl_socket_pool(); | 
| 554     else | 554     else | 
| 555       ssl_pool = session_->GetSocketPoolForSSLWithProxy(*proxy_host_port); | 555       ssl_pool = session_->GetSocketPoolForSSLWithProxy(*proxy_host_port); | 
| 556 | 556 | 
| 557     if (preconnect_delegate_) { | 557     if (preconnect_delegate_) { | 
| 558       RequestSocketsForPool(ssl_pool, connection_group, ssl_params, | 558       RequestSocketsForPool(ssl_pool, connection_group, ssl_params, | 
| 559                             num_streams_, net_log_); | 559                             num_streams_, net_log_); | 
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 821     connection_->socket()->SetOmniboxSpeculation(); | 821     connection_->socket()->SetOmniboxSpeculation(); | 
| 822   // TODO(mbelshe): Add other motivations (like EARLY_LOAD_MOTIVATED). | 822   // TODO(mbelshe): Add other motivations (like EARLY_LOAD_MOTIVATED). | 
| 823 } | 823 } | 
| 824 | 824 | 
| 825 bool HttpStreamRequest::IsHttpsProxyAndHttpUrl() { | 825 bool HttpStreamRequest::IsHttpsProxyAndHttpUrl() { | 
| 826   return proxy_info()->is_https() && request_info().url.SchemeIs("http"); | 826   return proxy_info()->is_https() && request_info().url.SchemeIs("http"); | 
| 827 } | 827 } | 
| 828 | 828 | 
| 829 // Returns a newly create SSLSocketParams, and sets several | 829 // Returns a newly create SSLSocketParams, and sets several | 
| 830 // fields of ssl_config_. | 830 // fields of ssl_config_. | 
| 831 scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSslParams( | 831 scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSSLParams( | 
| 832     scoped_refptr<TCPSocketParams> tcp_params, | 832     scoped_refptr<TCPSocketParams> tcp_params, | 
| 833     scoped_refptr<HttpProxySocketParams> http_proxy_params, | 833     scoped_refptr<HttpProxySocketParams> http_proxy_params, | 
| 834     scoped_refptr<SOCKSSocketParams> socks_params, | 834     scoped_refptr<SOCKSSocketParams> socks_params, | 
| 835     ProxyServer::Scheme proxy_scheme, | 835     ProxyServer::Scheme proxy_scheme, | 
| 836     std::string hostname, | 836     const HostPortPair& host_and_port, | 
| 837     bool want_spdy_over_npn) { | 837     bool want_spdy_over_npn) { | 
| 838 | 838 | 
| 839   if (factory_->IsTLSIntolerantServer(request_info().url)) { | 839   if (factory_->IsTLSIntolerantServer(request_info().url)) { | 
| 840     LOG(WARNING) << "Falling back to SSLv3 because host is TLS intolerant: " | 840     LOG(WARNING) << "Falling back to SSLv3 because host is TLS intolerant: " | 
| 841         << GetHostAndPort(request_info().url); | 841         << GetHostAndPort(request_info().url); | 
| 842     ssl_config()->ssl3_fallback = true; | 842     ssl_config()->ssl3_fallback = true; | 
| 843     ssl_config()->tls1_enabled = false; | 843     ssl_config()->tls1_enabled = false; | 
| 844   } | 844   } | 
| 845 | 845 | 
| 846   UMA_HISTOGRAM_ENUMERATION("Net.ConnectionUsedSSLv3Fallback", | 846   UMA_HISTOGRAM_ENUMERATION("Net.ConnectionUsedSSLv3Fallback", | 
| 847                             static_cast<int>(ssl_config()->ssl3_fallback), 2); | 847                             static_cast<int>(ssl_config()->ssl3_fallback), 2); | 
| 848 | 848 | 
| 849   int load_flags = request_info().load_flags; | 849   int load_flags = request_info().load_flags; | 
| 850   if (HttpStreamFactory::ignore_certificate_errors()) | 850   if (HttpStreamFactory::ignore_certificate_errors()) | 
| 851     load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | 851     load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | 
| 852   if (request_info().load_flags & LOAD_VERIFY_EV_CERT) | 852   if (request_info().load_flags & LOAD_VERIFY_EV_CERT) | 
| 853     ssl_config()->verify_ev_cert = true; | 853     ssl_config()->verify_ev_cert = true; | 
| 854 | 854 | 
| 855   if (proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTP || | 855   if (proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTP || | 
| 856       proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTPS) { | 856       proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTPS) { | 
| 857     ssl_config()->mitm_proxies_allowed = true; | 857     ssl_config()->mitm_proxies_allowed = true; | 
| 858   } | 858   } | 
| 859 | 859 | 
| 860   scoped_refptr<SSLSocketParams> ssl_params( | 860   scoped_refptr<SSLSocketParams> ssl_params( | 
| 861       new SSLSocketParams(tcp_params, socks_params, http_proxy_params, | 861       new SSLSocketParams(tcp_params, socks_params, http_proxy_params, | 
| 862                           proxy_scheme, hostname, | 862                           proxy_scheme, host_and_port, | 
| 863                           *ssl_config(), load_flags, | 863                           *ssl_config(), load_flags, | 
| 864                           force_spdy_always_ && force_spdy_over_ssl_, | 864                           force_spdy_always_ && force_spdy_over_ssl_, | 
| 865                           want_spdy_over_npn)); | 865                           want_spdy_over_npn)); | 
| 866 | 866 | 
| 867   return ssl_params; | 867   return ssl_params; | 
| 868 } | 868 } | 
| 869 | 869 | 
| 870 | 870 | 
| 871 void HttpStreamRequest::MarkBrokenAlternateProtocolAndFallback() { | 871 void HttpStreamRequest::MarkBrokenAlternateProtocolAndFallback() { | 
| 872   // We have to: | 872   // We have to: | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1039                                  base::TimeDelta::FromMinutes(6), | 1039                                  base::TimeDelta::FromMinutes(6), | 
| 1040                                  100); | 1040                                  100); | 
| 1041       break; | 1041       break; | 
| 1042     default: | 1042     default: | 
| 1043       NOTREACHED(); | 1043       NOTREACHED(); | 
| 1044       break; | 1044       break; | 
| 1045   } | 1045   } | 
| 1046 } | 1046 } | 
| 1047 | 1047 | 
| 1048 }  // namespace net | 1048 }  // namespace net | 
| OLD | NEW | 
|---|