Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: net/http/http_proxy_client_socket.cc

Issue 8502024: Allow chrome to handle 407 auth challenges to CONNECT requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove inline virtuals Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 HttpProxyClientSocket::~HttpProxyClientSocket() { 62 HttpProxyClientSocket::~HttpProxyClientSocket() {
63 Disconnect(); 63 Disconnect();
64 } 64 }
65 65
66 int HttpProxyClientSocket::RestartWithAuth(OldCompletionCallback* callback) { 66 int HttpProxyClientSocket::RestartWithAuth(OldCompletionCallback* callback) {
67 DCHECK_EQ(STATE_NONE, next_state_); 67 DCHECK_EQ(STATE_NONE, next_state_);
68 DCHECK(!user_callback_); 68 DCHECK(!user_callback_);
69 69
70 int rv = PrepareForAuthRestart(); 70 int rv = PrepareForAuthRestart();
71 if (rv != OK) 71 if (rv != OK || next_state_ == STATE_NONE)
72 return rv; 72 return rv;
73 73
74 rv = DoLoop(OK); 74 rv = DoLoop(OK);
75 if (rv == ERR_IO_PENDING) 75 if (rv == ERR_IO_PENDING)
76 user_callback_ = callback; 76 user_callback_ = callback;
77 return rv; 77 return rv;
78 } 78 }
79 79
80 const
81 scoped_refptr<HttpAuthController>& HttpProxyClientSocket::auth_controller() {
82 return auth_;
83 }
84
80 const HttpResponseInfo* HttpProxyClientSocket::GetConnectResponseInfo() const { 85 const HttpResponseInfo* HttpProxyClientSocket::GetConnectResponseInfo() const {
81 return response_.headers ? &response_ : NULL; 86 return response_.headers ? &response_ : NULL;
82 } 87 }
83 88
84 HttpStream* HttpProxyClientSocket::CreateConnectResponseStream() { 89 HttpStream* HttpProxyClientSocket::CreateConnectResponseStream() {
85 return new HttpBasicStream(transport_.release(), 90 return new HttpBasicStream(transport_.release(),
86 http_stream_parser_.release(), false); 91 http_stream_parser_.release(), false);
87 } 92 }
88 93
89 94
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // We don't need to drain the response body, so we act as if we had drained 249 // We don't need to drain the response body, so we act as if we had drained
245 // the response body. 250 // the response body.
246 return DidDrainBodyForAuthRestart(keep_alive); 251 return DidDrainBodyForAuthRestart(keep_alive);
247 } 252 }
248 253
249 int HttpProxyClientSocket::DidDrainBodyForAuthRestart(bool keep_alive) { 254 int HttpProxyClientSocket::DidDrainBodyForAuthRestart(bool keep_alive) {
250 if (keep_alive && transport_->socket()->IsConnectedAndIdle()) { 255 if (keep_alive && transport_->socket()->IsConnectedAndIdle()) {
251 next_state_ = STATE_GENERATE_AUTH_TOKEN; 256 next_state_ = STATE_GENERATE_AUTH_TOKEN;
252 transport_->set_is_reused(true); 257 transport_->set_is_reused(true);
253 } else { 258 } else {
254 // This assumes that the underlying transport socket is a TCP socket, 259 next_state_ = STATE_NONE;
255 // since only TCP sockets are restartable.
256 next_state_ = STATE_TCP_RESTART;
257 transport_->socket()->Disconnect();
258 } 260 }
259 261
260 // Reset the other member variables. 262 // Reset the other member variables.
261 drain_buf_ = NULL; 263 drain_buf_ = NULL;
262 parser_buf_ = NULL; 264 parser_buf_ = NULL;
263 http_stream_parser_.reset(); 265 http_stream_parser_.reset();
264 request_line_.clear(); 266 request_line_.clear();
265 request_headers_.Clear(); 267 request_headers_.Clear();
266 response_ = HttpResponseInfo(); 268 response_ = HttpResponseInfo();
267 return OK; 269 return OK;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 net_log_.EndEventWithNetErrorCode( 342 net_log_.EndEventWithNetErrorCode(
341 NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_READ_HEADERS, rv); 343 NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_READ_HEADERS, rv);
342 break; 344 break;
343 case STATE_DRAIN_BODY: 345 case STATE_DRAIN_BODY:
344 DCHECK_EQ(OK, rv); 346 DCHECK_EQ(OK, rv);
345 rv = DoDrainBody(); 347 rv = DoDrainBody();
346 break; 348 break;
347 case STATE_DRAIN_BODY_COMPLETE: 349 case STATE_DRAIN_BODY_COMPLETE:
348 rv = DoDrainBodyComplete(rv); 350 rv = DoDrainBodyComplete(rv);
349 break; 351 break;
350 case STATE_TCP_RESTART:
351 DCHECK_EQ(OK, rv);
352 rv = DoTCPRestart();
353 break;
354 case STATE_TCP_RESTART_COMPLETE:
355 rv = DoTCPRestartComplete(rv);
356 break;
357 case STATE_DONE: 352 case STATE_DONE:
358 break; 353 break;
359 default: 354 default:
360 NOTREACHED() << "bad state"; 355 NOTREACHED() << "bad state";
361 rv = ERR_UNEXPECTED; 356 rv = ERR_UNEXPECTED;
362 break; 357 break;
363 } 358 }
364 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE && 359 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE &&
365 next_state_ != STATE_DONE); 360 next_state_ != STATE_DONE);
366 return rv; 361 return rv;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 return result; 476 return result;
482 477
483 if (http_stream_parser_->IsResponseBodyComplete()) 478 if (http_stream_parser_->IsResponseBodyComplete())
484 return DidDrainBodyForAuthRestart(true); 479 return DidDrainBodyForAuthRestart(true);
485 480
486 // Keep draining. 481 // Keep draining.
487 next_state_ = STATE_DRAIN_BODY; 482 next_state_ = STATE_DRAIN_BODY;
488 return OK; 483 return OK;
489 } 484 }
490 485
491 int HttpProxyClientSocket::DoTCPRestart() {
492 next_state_ = STATE_TCP_RESTART_COMPLETE;
493 return transport_->socket()->Connect(&io_callback_);
494 }
495
496 int HttpProxyClientSocket::DoTCPRestartComplete(int result) {
497 if (result != OK)
498 return result;
499
500 next_state_ = STATE_GENERATE_AUTH_TOKEN;
501 return result;
502 }
503
504 } // namespace net 486 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698