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

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

Issue 9148011: Allow chrome to handle 407 auth challenges to CONNECT requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months 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_stream_factory_impl_job.h" 5 #include "net/http/http_stream_factory_impl_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 session_->http_server_properties(); 174 session_->http_server_properties();
175 if (http_server_properties && 175 if (http_server_properties &&
176 http_server_properties->SupportsSpdy(origin_server)) { 176 http_server_properties->SupportsSpdy(origin_server)) {
177 num_streams_ = 1; 177 num_streams_ = 1;
178 } else { 178 } else {
179 num_streams_ = num_streams; 179 num_streams_ = num_streams;
180 } 180 }
181 return StartInternal(); 181 return StartInternal();
182 } 182 }
183 183
184 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( 184 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth() {
185 const AuthCredentials& credentials) { 185 // We run this asynchronously to ensure that we don't invoke
186 DCHECK(establishing_tunnel_); 186 // the callback (which might cause the caller to be deleted)
187 next_state_ = STATE_RESTART_TUNNEL_AUTH; 187 // while the caller is waiting for this method to return.
188 stream_.reset(); 188 MessageLoop::current()->PostTask(
189 return RunLoop(OK); 189 FROM_HERE,
190 base::Bind(&HttpStreamFactoryImpl::Job::DoRestartTunnelWithProxyAuth,
191 ptr_factory_.GetWeakPtr()));
192 return ERR_IO_PENDING;
193 }
194
195 void HttpStreamFactoryImpl::Job::DoRestartTunnelWithProxyAuth() {
196 LOG(INFO) << __FUNCTION__;
vandebo (ex-Chrome) 2012/01/20 21:58:20 extra
Ryan Hamilton 2012/01/23 18:37:27 Done.
197 tunnel_auth_handled_callback_.Run(OK);
198 tunnel_auth_handled_callback_.Reset();
190 } 199 }
191 200
192 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { 201 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const {
193 switch (next_state_) { 202 switch (next_state_) {
194 case STATE_RESOLVE_PROXY_COMPLETE: 203 case STATE_RESOLVE_PROXY_COMPLETE:
195 return session_->proxy_service()->GetLoadState(pac_request_); 204 return session_->proxy_service()->GetLoadState(pac_request_);
196 case STATE_CREATE_STREAM_COMPLETE: 205 case STATE_CREATE_STREAM_COMPLETE:
197 return connection_->GetLoadState(); 206 return connection_->GetLoadState();
198 case STATE_INIT_CONNECTION_COMPLETE: 207 case STATE_INIT_CONNECTION_COMPLETE:
199 return LOAD_STATE_SENDING_REQUEST; 208 return LOAD_STATE_SENDING_REQUEST;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 HttpAuthController* auth_controller) { 344 HttpAuthController* auth_controller) {
336 DCHECK(!IsPreconnecting()); 345 DCHECK(!IsPreconnecting());
337 if (IsOrphaned()) 346 if (IsOrphaned())
338 stream_factory_->OnOrphanedJobComplete(this); 347 stream_factory_->OnOrphanedJobComplete(this);
339 else 348 else
340 request_->OnNeedsProxyAuth( 349 request_->OnNeedsProxyAuth(
341 this, response, server_ssl_config_, proxy_info_, auth_controller); 350 this, response, server_ssl_config_, proxy_info_, auth_controller);
342 // |this| may be deleted after this call. 351 // |this| may be deleted after this call.
343 } 352 }
344 353
354 void HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback(
355 const HttpResponseInfo& response_info,
356 HttpAuthController* auth_controller,
357 CompletionCallback callback) {
358 LOG(INFO) << __FUNCTION__;
vandebo (ex-Chrome) 2012/01/20 21:58:20 extra
Ryan Hamilton 2012/01/23 18:37:27 Done.
359 DCHECK(!callback.is_null());
360 DCHECK(tunnel_auth_handled_callback_.is_null());
361 tunnel_auth_handled_callback_ = callback;
362 request_->OnNeedsProxyAuth(
363 this, response_info, server_ssl_config_, proxy_info_, auth_controller);
364 // |this| may be deleted after this call.
365 }
366
345 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback( 367 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback(
346 SSLCertRequestInfo* cert_info) { 368 SSLCertRequestInfo* cert_info) {
347 DCHECK(!IsPreconnecting()); 369 DCHECK(!IsPreconnecting());
348 if (IsOrphaned()) 370 if (IsOrphaned())
349 stream_factory_->OnOrphanedJobComplete(this); 371 stream_factory_->OnOrphanedJobComplete(this);
350 else 372 else
351 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info); 373 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info);
352 // |this| may be deleted after this call. 374 // |this| may be deleted after this call.
353 } 375 }
354 376
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 return ERR_IO_PENDING; 431 return ERR_IO_PENDING;
410 } 432 }
411 433
412 switch (result) { 434 switch (result) {
413 case ERR_PROXY_AUTH_REQUESTED: 435 case ERR_PROXY_AUTH_REQUESTED:
414 { 436 {
415 DCHECK(connection_.get()); 437 DCHECK(connection_.get());
416 DCHECK(connection_->socket()); 438 DCHECK(connection_->socket());
417 DCHECK(establishing_tunnel_); 439 DCHECK(establishing_tunnel_);
418 440
419 HttpProxyClientSocket* http_proxy_socket = 441 ProxyClientSocket* proxy_socket =
420 static_cast<HttpProxyClientSocket*>(connection_->socket()); 442 static_cast<ProxyClientSocket*>(connection_->socket());
421 const HttpResponseInfo* tunnel_auth_response = 443 const HttpResponseInfo* tunnel_auth_response =
422 http_proxy_socket->GetConnectResponseInfo(); 444 proxy_socket->GetConnectResponseInfo();
423 445
424 next_state_ = STATE_WAITING_USER_ACTION; 446 next_state_ = STATE_WAITING_USER_ACTION;
425 MessageLoop::current()->PostTask( 447 MessageLoop::current()->PostTask(
426 FROM_HERE, 448 FROM_HERE,
427 base::Bind( 449 base::Bind(
428 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, 450 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback,
429 ptr_factory_.GetWeakPtr(), 451 ptr_factory_.GetWeakPtr(),
430 *tunnel_auth_response, 452 *tunnel_auth_response,
431 http_proxy_socket->auth_controller())); 453 proxy_socket->GetAuthController()));
432 } 454 }
433 return ERR_IO_PENDING; 455 return ERR_IO_PENDING;
434 456
435 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: 457 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
436 MessageLoop::current()->PostTask( 458 MessageLoop::current()->PostTask(
437 FROM_HERE, 459 FROM_HERE,
438 base::Bind( 460 base::Bind(
439 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, 461 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback,
440 ptr_factory_.GetWeakPtr(), 462 ptr_factory_.GetWeakPtr(),
441 connection_->ssl_error_response_info().cert_request_info)); 463 connection_->ssl_error_response_info().cert_request_info));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 request_info_.extra_headers, 736 request_info_.extra_headers,
715 request_info_.load_flags, 737 request_info_.load_flags,
716 request_info_.priority, 738 request_info_.priority,
717 session_, 739 session_,
718 proxy_info_, 740 proxy_info_,
719 ShouldForceSpdySSL(), 741 ShouldForceSpdySSL(),
720 want_spdy_over_npn, 742 want_spdy_over_npn,
721 server_ssl_config_, 743 server_ssl_config_,
722 proxy_ssl_config_, 744 proxy_ssl_config_,
723 net_log_, 745 net_log_,
724 num_streams_); 746 num_streams_,
747 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback,
748 ptr_factory_.GetWeakPtr()));
725 } else { 749 } else {
726 return InitSocketHandleForHttpRequest( 750 return InitSocketHandleForHttpRequest(
727 origin_url_, request_info_.extra_headers, request_info_.load_flags, 751 origin_url_, request_info_.extra_headers, request_info_.load_flags,
728 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(), 752 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(),
729 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_, 753 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_,
730 connection_.get(), io_callback_); 754 connection_.get(),
755 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback,
756 ptr_factory_.GetWeakPtr()),
757 io_callback_);
731 } 758 }
732 } 759 }
733 760
734 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { 761 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) {
735 if (IsPreconnecting()) { 762 if (IsPreconnecting()) {
736 DCHECK_EQ(OK, result); 763 DCHECK_EQ(OK, result);
737 return OK; 764 return OK;
738 } 765 }
739 766
740 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable 767 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 return false; 1235 return false;
1209 } 1236 }
1210 if (request_info_.method != "GET" && request_info_.method != "HEAD") { 1237 if (request_info_.method != "GET" && request_info_.method != "HEAD") {
1211 return false; 1238 return false;
1212 } 1239 }
1213 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( 1240 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining(
1214 origin_); 1241 origin_);
1215 } 1242 }
1216 1243
1217 } // namespace net 1244 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698