| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, const scoped_refptr<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), |
| 61 auth_(auth), |
| 60 tunnel_(tunnel), | 62 tunnel_(tunnel), |
| 61 auth_(auth), | |
| 62 endpoint_(endpoint), | |
| 63 net_log_(transport_socket->socket()->NetLog()) { | 63 net_log_(transport_socket->socket()->NetLog()) { |
| 64 DCHECK_EQ(tunnel, auth != NULL); | 64 DCHECK_EQ(tunnel, auth != NULL); |
| 65 if (tunnel) | |
| 66 auth->set_net_log(net_log_); | |
| 67 // Synthesize the bits of a request that we actually use. | 65 // Synthesize the bits of a request that we actually use. |
| 68 request_.url = request_url; | 66 request_.url = request_url; |
| 69 request_.method = "GET"; | 67 request_.method = "GET"; |
| 70 } | 68 } |
| 71 | 69 |
| 72 HttpProxyClientSocket::~HttpProxyClientSocket() { | 70 HttpProxyClientSocket::~HttpProxyClientSocket() { |
| 73 Disconnect(); | 71 Disconnect(); |
| 74 } | 72 } |
| 75 | 73 |
| 76 int HttpProxyClientSocket::Connect(CompletionCallback* callback) { | 74 int HttpProxyClientSocket::Connect(CompletionCallback* callback) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 rv = ERR_UNEXPECTED; | 277 rv = ERR_UNEXPECTED; |
| 280 break; | 278 break; |
| 281 } | 279 } |
| 282 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE | 280 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE |
| 283 && next_state_ != STATE_DONE); | 281 && next_state_ != STATE_DONE); |
| 284 return rv; | 282 return rv; |
| 285 } | 283 } |
| 286 | 284 |
| 287 int HttpProxyClientSocket::DoGenerateAuthToken() { | 285 int HttpProxyClientSocket::DoGenerateAuthToken() { |
| 288 next_state_ = STATE_GENERATE_AUTH_TOKEN_COMPLETE; | 286 next_state_ = STATE_GENERATE_AUTH_TOKEN_COMPLETE; |
| 289 return auth_->MaybeGenerateAuthToken(&request_, &io_callback_); | 287 return auth_->MaybeGenerateAuthToken(&request_, &io_callback_, net_log_); |
| 290 } | 288 } |
| 291 | 289 |
| 292 int HttpProxyClientSocket::DoGenerateAuthTokenComplete(int result) { | 290 int HttpProxyClientSocket::DoGenerateAuthTokenComplete(int result) { |
| 293 DCHECK_NE(ERR_IO_PENDING, result); | 291 DCHECK_NE(ERR_IO_PENDING, result); |
| 294 if (result == OK) | 292 if (result == OK) |
| 295 next_state_ = STATE_SEND_REQUEST; | 293 next_state_ = STATE_SEND_REQUEST; |
| 296 return result; | 294 return result; |
| 297 } | 295 } |
| 298 | 296 |
| 299 int HttpProxyClientSocket::DoSendRequest() { | 297 int HttpProxyClientSocket::DoSendRequest() { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 return DidDrainBodyForAuthRestart(true); | 402 return DidDrainBodyForAuthRestart(true); |
| 405 | 403 |
| 406 // Keep draining. | 404 // Keep draining. |
| 407 next_state_ = STATE_DRAIN_BODY; | 405 next_state_ = STATE_DRAIN_BODY; |
| 408 return OK; | 406 return OK; |
| 409 } | 407 } |
| 410 | 408 |
| 411 int HttpProxyClientSocket::HandleAuthChallenge() { | 409 int HttpProxyClientSocket::HandleAuthChallenge() { |
| 412 DCHECK(response_.headers); | 410 DCHECK(response_.headers); |
| 413 | 411 |
| 414 int rv = auth_->HandleAuthChallenge(response_.headers, false, true); | 412 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); |
| 415 response_.auth_challenge = auth_->auth_info(); | 413 response_.auth_challenge = auth_->auth_info(); |
| 416 if (rv == OK) | 414 if (rv == OK) |
| 417 return ERR_PROXY_AUTH_REQUESTED; | 415 return ERR_PROXY_AUTH_REQUESTED; |
| 418 | 416 |
| 419 return rv; | 417 return rv; |
| 420 } | 418 } |
| 421 | 419 |
| 422 } // namespace net | 420 } // namespace net |
| OLD | NEW |