| 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_proxy_client_socket.h" | 5 #include "net/http/http_proxy_client_socket.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/host_port_pair.h" | 9 #include "net/base/host_port_pair.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 &user_agent)) | 43 &user_agent)) |
| 44 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent); | 44 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent); |
| 45 | 45 |
| 46 request_headers->MergeFrom(authorization_headers); | 46 request_headers->MergeFrom(authorization_headers); |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 HttpProxyClientSocket::HttpProxyClientSocket( | 51 HttpProxyClientSocket::HttpProxyClientSocket( |
| 52 ClientSocketHandle* transport_socket, const GURL& request_url, | 52 ClientSocketHandle* transport_socket, const GURL& request_url, |
| 53 const HostPortPair& endpoint, const scoped_refptr<HttpAuthController>& auth, | 53 const HostPortPair& endpoint, HttpAuthController* auth, |
| 54 bool tunnel) | 54 bool tunnel) |
| 55 : ALLOW_THIS_IN_INITIALIZER_LIST( | 55 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 56 io_callback_(this, &HttpProxyClientSocket::OnIOComplete)), | 56 io_callback_(this, &HttpProxyClientSocket::OnIOComplete)), |
| 57 next_state_(STATE_NONE), | 57 next_state_(STATE_NONE), |
| 58 user_callback_(NULL), | 58 user_callback_(NULL), |
| 59 transport_(transport_socket), | 59 transport_(transport_socket), |
| 60 endpoint_(endpoint), | 60 endpoint_(endpoint), |
| 61 auth_(auth), | 61 auth_(auth), |
| 62 tunnel_(tunnel), | 62 tunnel_(tunnel), |
| 63 net_log_(transport_socket->socket()->NetLog()) { | 63 net_log_(transport_socket->socket()->NetLog()) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 DCHECK_EQ(STATE_NONE, next_state_); | 85 DCHECK_EQ(STATE_NONE, next_state_); |
| 86 next_state_ = STATE_GENERATE_AUTH_TOKEN; | 86 next_state_ = STATE_GENERATE_AUTH_TOKEN; |
| 87 | 87 |
| 88 int rv = DoLoop(OK); | 88 int rv = DoLoop(OK); |
| 89 if (rv == ERR_IO_PENDING) | 89 if (rv == ERR_IO_PENDING) |
| 90 user_callback_ = callback; | 90 user_callback_ = callback; |
| 91 return rv; | 91 return rv; |
| 92 } | 92 } |
| 93 | 93 |
| 94 int HttpProxyClientSocket::RestartWithAuth(CompletionCallback* callback) { | 94 int HttpProxyClientSocket::RestartWithAuth(const std::wstring& username, |
| 95 const std::wstring& password, |
| 96 CompletionCallback* callback) { |
| 95 DCHECK_EQ(STATE_NONE, next_state_); | 97 DCHECK_EQ(STATE_NONE, next_state_); |
| 96 DCHECK(!user_callback_); | 98 DCHECK(!user_callback_); |
| 97 | 99 |
| 100 auth_->SetCredentials(username, password); |
| 101 auth_->PrepareForAuthRestart(); |
| 102 |
| 98 int rv = PrepareForAuthRestart(); | 103 int rv = PrepareForAuthRestart(); |
| 99 if (rv != OK) | 104 if (rv != OK) |
| 100 return rv; | 105 return rv; |
| 101 | 106 |
| 102 rv = DoLoop(OK); | 107 rv = DoLoop(OK); |
| 103 if (rv == ERR_IO_PENDING) | 108 if (rv == ERR_IO_PENDING) |
| 104 user_callback_ = callback; | 109 user_callback_ = callback; |
| 105 return rv; | 110 return rv; |
| 106 } | 111 } |
| 107 | 112 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 416 |
| 412 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); | 417 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); |
| 413 response_.auth_challenge = auth_->auth_info(); | 418 response_.auth_challenge = auth_->auth_info(); |
| 414 if (rv == OK) | 419 if (rv == OK) |
| 415 return ERR_PROXY_AUTH_REQUESTED; | 420 return ERR_PROXY_AUTH_REQUESTED; |
| 416 | 421 |
| 417 return rv; | 422 return rv; |
| 418 } | 423 } |
| 419 | 424 |
| 420 } // namespace net | 425 } // namespace net |
| OLD | NEW |