| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 base::TimeDelta HttpProxyClientSocket::GetConnectTimeMicros() const { | 207 base::TimeDelta HttpProxyClientSocket::GetConnectTimeMicros() const { |
| 208 if (transport_.get() && transport_->socket()) { | 208 if (transport_.get() && transport_->socket()) { |
| 209 return transport_->socket()->GetConnectTimeMicros(); | 209 return transport_->socket()->GetConnectTimeMicros(); |
| 210 } | 210 } |
| 211 NOTREACHED(); | 211 NOTREACHED(); |
| 212 return base::TimeDelta::FromMicroseconds(-1); | 212 return base::TimeDelta::FromMicroseconds(-1); |
| 213 } | 213 } |
| 214 | 214 |
| 215 int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len, | 215 int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len, |
| 216 OldCompletionCallback* callback) { | 216 OldCompletionCallback* callback) { |
| 217 DCHECK(!old_user_callback_); | 217 DCHECK(!old_user_callback_ && user_callback_.is_null()); |
| 218 if (next_state_ != STATE_DONE) { | 218 if (next_state_ != STATE_DONE) { |
| 219 // We're trying to read the body of the response but we're still trying | 219 // We're trying to read the body of the response but we're still trying |
| 220 // to establish an SSL tunnel through the proxy. We can't read these | 220 // to establish an SSL tunnel through the proxy. We can't read these |
| 221 // bytes when establishing a tunnel because they might be controlled by |
| 222 // an active network attacker. We don't worry about this for HTTP |
| 223 // because an active network attacker can already control HTTP sessions. |
| 224 // We reach this case when the user cancels a 407 proxy auth prompt. |
| 225 // See http://crbug.com/8473. |
| 226 DCHECK_EQ(407, response_.headers->response_code()); |
| 227 LogBlockedTunnelResponse(response_.headers->response_code()); |
| 228 |
| 229 return ERR_TUNNEL_CONNECTION_FAILED; |
| 230 } |
| 231 |
| 232 return transport_->socket()->Read(buf, buf_len, callback); |
| 233 } |
| 234 int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len, |
| 235 const CompletionCallback& callback) { |
| 236 DCHECK(!old_user_callback_ && user_callback_.is_null()); |
| 237 if (next_state_ != STATE_DONE) { |
| 238 // We're trying to read the body of the response but we're still trying |
| 239 // to establish an SSL tunnel through the proxy. We can't read these |
| 221 // bytes when establishing a tunnel because they might be controlled by | 240 // bytes when establishing a tunnel because they might be controlled by |
| 222 // an active network attacker. We don't worry about this for HTTP | 241 // an active network attacker. We don't worry about this for HTTP |
| 223 // because an active network attacker can already control HTTP sessions. | 242 // because an active network attacker can already control HTTP sessions. |
| 224 // We reach this case when the user cancels a 407 proxy auth prompt. | 243 // We reach this case when the user cancels a 407 proxy auth prompt. |
| 225 // See http://crbug.com/8473. | 244 // See http://crbug.com/8473. |
| 226 DCHECK_EQ(407, response_.headers->response_code()); | 245 DCHECK_EQ(407, response_.headers->response_code()); |
| 227 LogBlockedTunnelResponse(response_.headers->response_code()); | 246 LogBlockedTunnelResponse(response_.headers->response_code()); |
| 228 | 247 |
| 229 return ERR_TUNNEL_CONNECTION_FAILED; | 248 return ERR_TUNNEL_CONNECTION_FAILED; |
| 230 } | 249 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 516 |
| 498 if (http_stream_parser_->IsResponseBodyComplete()) | 517 if (http_stream_parser_->IsResponseBodyComplete()) |
| 499 return DidDrainBodyForAuthRestart(true); | 518 return DidDrainBodyForAuthRestart(true); |
| 500 | 519 |
| 501 // Keep draining. | 520 // Keep draining. |
| 502 next_state_ = STATE_DRAIN_BODY; | 521 next_state_ = STATE_DRAIN_BODY; |
| 503 return OK; | 522 return OK; |
| 504 } | 523 } |
| 505 | 524 |
| 506 } // namespace net | 525 } // namespace net |
| OLD | NEW |