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_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 const std::wstring& username, | 307 const std::wstring& username, |
308 const std::wstring& password, | 308 const std::wstring& password, |
309 CompletionCallback* callback) { | 309 CompletionCallback* callback) { |
310 HttpAuth::Target target = pending_auth_target_; | 310 HttpAuth::Target target = pending_auth_target_; |
311 if (target == HttpAuth::AUTH_NONE) { | 311 if (target == HttpAuth::AUTH_NONE) { |
312 NOTREACHED(); | 312 NOTREACHED(); |
313 return ERR_UNEXPECTED; | 313 return ERR_UNEXPECTED; |
314 } | 314 } |
315 pending_auth_target_ = HttpAuth::AUTH_NONE; | 315 pending_auth_target_ = HttpAuth::AUTH_NONE; |
316 | 316 |
317 auth_controllers_[target]->ResetAuth(username, password); | |
318 | |
319 if (target == HttpAuth::AUTH_PROXY && using_ssl_ && proxy_info_.is_http()) { | 317 if (target == HttpAuth::AUTH_PROXY && using_ssl_ && proxy_info_.is_http()) { |
320 DCHECK(establishing_tunnel_); | 318 DCHECK(establishing_tunnel_); |
| 319 DCHECK(auth_controllers_[target].get() == NULL); |
321 next_state_ = STATE_INIT_CONNECTION; | 320 next_state_ = STATE_INIT_CONNECTION; |
| 321 auth_controllers_[target].reset(new HttpAuthController(target, |
| 322 AuthURL(target), |
| 323 session_)); |
| 324 auth_controllers_[target]->SetCredentials(username, password); |
322 ResetStateForRestart(); | 325 ResetStateForRestart(); |
323 } else { | 326 } else { |
| 327 auth_controllers_[target]->SetCredentials(username, password); |
| 328 auth_controllers_[target]->PrepareForAuthRestart(); |
324 PrepareForAuthRestart(target); | 329 PrepareForAuthRestart(target); |
325 } | 330 } |
326 | 331 |
327 DCHECK(user_callback_ == NULL); | 332 DCHECK(user_callback_ == NULL); |
328 int rv = DoLoop(OK); | 333 int rv = DoLoop(OK); |
329 if (rv == ERR_IO_PENDING) | 334 if (rv == ERR_IO_PENDING) |
330 user_callback_ = callback; | 335 user_callback_ = callback; |
331 | 336 |
332 return rv; | 337 return rv; |
333 } | 338 } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 | 704 |
700 int HttpNetworkTransaction::DoInitConnection() { | 705 int HttpNetworkTransaction::DoInitConnection() { |
701 DCHECK(!connection_->is_initialized()); | 706 DCHECK(!connection_->is_initialized()); |
702 DCHECK(proxy_info_.proxy_server().is_valid()); | 707 DCHECK(proxy_info_.proxy_server().is_valid()); |
703 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 708 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
704 | 709 |
705 // Now that the proxy server has been resolved, create the auth_controllers_. | 710 // Now that the proxy server has been resolved, create the auth_controllers_. |
706 for (int i = 0; i < HttpAuth::AUTH_NUM_TARGETS; i++) { | 711 for (int i = 0; i < HttpAuth::AUTH_NUM_TARGETS; i++) { |
707 HttpAuth::Target target = static_cast<HttpAuth::Target>(i); | 712 HttpAuth::Target target = static_cast<HttpAuth::Target>(i); |
708 if (!auth_controllers_[target].get()) | 713 if (!auth_controllers_[target].get()) |
709 auth_controllers_[target] = new HttpAuthController(target, | 714 auth_controllers_[target].reset(new HttpAuthController(target, |
710 AuthURL(target), | 715 AuthURL(target), |
711 session_); | 716 session_)); |
712 } | 717 } |
713 | 718 |
714 bool want_spdy = alternate_protocol_mode_ == kUsingAlternateProtocol | 719 bool want_spdy = alternate_protocol_mode_ == kUsingAlternateProtocol |
715 && alternate_protocol_ == HttpAlternateProtocols::NPN_SPDY_1; | 720 && alternate_protocol_ == HttpAlternateProtocols::NPN_SPDY_1; |
716 using_ssl_ = request_->url.SchemeIs("https") || want_spdy; | 721 using_ssl_ = request_->url.SchemeIs("https") || want_spdy; |
717 using_spdy_ = false; | 722 using_spdy_ = false; |
718 response_.was_fetched_via_proxy = !proxy_info_.is_direct(); | 723 response_.was_fetched_via_proxy = !proxy_info_.is_direct(); |
719 | 724 |
720 // Use the fixed testing ports if they've been provided. | 725 // Use the fixed testing ports if they've been provided. |
721 if (using_ssl_) { | 726 if (using_ssl_) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 request_->referrer, | 763 request_->referrer, |
759 disable_resolver_cache); | 764 disable_resolver_cache); |
760 } else { | 765 } else { |
761 ProxyServer proxy_server = proxy_info_.proxy_server(); | 766 ProxyServer proxy_server = proxy_info_.proxy_server(); |
762 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); | 767 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); |
763 scoped_refptr<TCPSocketParams> proxy_tcp_params = | 768 scoped_refptr<TCPSocketParams> proxy_tcp_params = |
764 new TCPSocketParams(*proxy_host_port, request_->priority, | 769 new TCPSocketParams(*proxy_host_port, request_->priority, |
765 request_->referrer, disable_resolver_cache); | 770 request_->referrer, disable_resolver_cache); |
766 | 771 |
767 if (proxy_info_.is_http()) { | 772 if (proxy_info_.is_http()) { |
768 scoped_refptr<HttpAuthController> http_proxy_auth; | 773 scoped_ptr<HttpAuthController> http_proxy_auth; |
769 if (using_ssl_) { | 774 if (using_ssl_) { |
770 http_proxy_auth = auth_controllers_[HttpAuth::AUTH_PROXY]; | 775 http_proxy_auth.reset( |
| 776 auth_controllers_[HttpAuth::AUTH_PROXY].release()); |
771 establishing_tunnel_ = true; | 777 establishing_tunnel_ = true; |
772 } | 778 } |
773 http_proxy_params = new HttpProxySocketParams(proxy_tcp_params, | 779 http_proxy_params = new HttpProxySocketParams(proxy_tcp_params, |
774 request_->url, endpoint_, | 780 request_->url, endpoint_, |
775 http_proxy_auth, | 781 http_proxy_auth.release(), |
776 using_ssl_); | 782 using_ssl_); |
777 } else { | 783 } else { |
778 DCHECK(proxy_info_.is_socks()); | 784 DCHECK(proxy_info_.is_socks()); |
779 char socks_version; | 785 char socks_version; |
780 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) | 786 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) |
781 socks_version = '5'; | 787 socks_version = '5'; |
782 else | 788 else |
783 socks_version = '4'; | 789 socks_version = '4'; |
784 connection_group = | 790 connection_group = |
785 StringPrintf("socks%c/%s", socks_version, connection_group.c_str()); | 791 StringPrintf("socks%c/%s", socks_version, connection_group.c_str()); |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 default: | 1794 default: |
1789 description = StringPrintf("Unknown state 0x%08X (%u)", state, state); | 1795 description = StringPrintf("Unknown state 0x%08X (%u)", state, state); |
1790 break; | 1796 break; |
1791 } | 1797 } |
1792 return description; | 1798 return description; |
1793 } | 1799 } |
1794 | 1800 |
1795 #undef STATE_CASE | 1801 #undef STATE_CASE |
1796 | 1802 |
1797 } // namespace net | 1803 } // namespace net |
OLD | NEW |