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

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
« no previous file with comments | « net/http/http_stream_factory_impl_job.h ('k') | net/http/http_stream_factory_impl_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 tunnel_auth_handled_callback_.Run(OK);
197 tunnel_auth_handled_callback_.Reset();
190 } 198 }
191 199
192 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { 200 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const {
193 switch (next_state_) { 201 switch (next_state_) {
194 case STATE_RESOLVE_PROXY_COMPLETE: 202 case STATE_RESOLVE_PROXY_COMPLETE:
195 return session_->proxy_service()->GetLoadState(pac_request_); 203 return session_->proxy_service()->GetLoadState(pac_request_);
196 case STATE_CREATE_STREAM_COMPLETE: 204 case STATE_CREATE_STREAM_COMPLETE:
197 return connection_->GetLoadState(); 205 return connection_->GetLoadState();
198 case STATE_INIT_CONNECTION_COMPLETE: 206 case STATE_INIT_CONNECTION_COMPLETE:
199 return LOAD_STATE_SENDING_REQUEST; 207 return LOAD_STATE_SENDING_REQUEST;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 HttpAuthController* auth_controller) { 343 HttpAuthController* auth_controller) {
336 DCHECK(!IsPreconnecting()); 344 DCHECK(!IsPreconnecting());
337 if (IsOrphaned()) 345 if (IsOrphaned())
338 stream_factory_->OnOrphanedJobComplete(this); 346 stream_factory_->OnOrphanedJobComplete(this);
339 else 347 else
340 request_->OnNeedsProxyAuth( 348 request_->OnNeedsProxyAuth(
341 this, response, server_ssl_config_, proxy_info_, auth_controller); 349 this, response, server_ssl_config_, proxy_info_, auth_controller);
342 // |this| may be deleted after this call. 350 // |this| may be deleted after this call.
343 } 351 }
344 352
353 void HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback(
354 const HttpResponseInfo& response_info,
355 HttpAuthController* auth_controller,
356 CompletionCallback callback) {
357 DCHECK(!callback.is_null());
358 DCHECK(tunnel_auth_handled_callback_.is_null());
359 tunnel_auth_handled_callback_ = callback;
360 request_->OnNeedsProxyAuth(
361 this, response_info, server_ssl_config_, proxy_info_, auth_controller);
362 // |this| may be deleted after this call.
363 }
364
345 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback( 365 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback(
346 SSLCertRequestInfo* cert_info) { 366 SSLCertRequestInfo* cert_info) {
347 DCHECK(!IsPreconnecting()); 367 DCHECK(!IsPreconnecting());
348 if (IsOrphaned()) 368 if (IsOrphaned())
349 stream_factory_->OnOrphanedJobComplete(this); 369 stream_factory_->OnOrphanedJobComplete(this);
350 else 370 else
351 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info); 371 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info);
352 // |this| may be deleted after this call. 372 // |this| may be deleted after this call.
353 } 373 }
354 374
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return ERR_IO_PENDING; 433 return ERR_IO_PENDING;
414 } 434 }
415 435
416 switch (result) { 436 switch (result) {
417 case ERR_PROXY_AUTH_REQUESTED: 437 case ERR_PROXY_AUTH_REQUESTED:
418 { 438 {
419 DCHECK(connection_.get()); 439 DCHECK(connection_.get());
420 DCHECK(connection_->socket()); 440 DCHECK(connection_->socket());
421 DCHECK(establishing_tunnel_); 441 DCHECK(establishing_tunnel_);
422 442
423 HttpProxyClientSocket* http_proxy_socket = 443 ProxyClientSocket* proxy_socket =
424 static_cast<HttpProxyClientSocket*>(connection_->socket()); 444 static_cast<ProxyClientSocket*>(connection_->socket());
425 const HttpResponseInfo* tunnel_auth_response = 445 const HttpResponseInfo* tunnel_auth_response =
426 http_proxy_socket->GetConnectResponseInfo(); 446 proxy_socket->GetConnectResponseInfo();
427 447
428 next_state_ = STATE_WAITING_USER_ACTION; 448 next_state_ = STATE_WAITING_USER_ACTION;
429 MessageLoop::current()->PostTask( 449 MessageLoop::current()->PostTask(
430 FROM_HERE, 450 FROM_HERE,
431 base::Bind( 451 base::Bind(
432 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, 452 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback,
433 ptr_factory_.GetWeakPtr(), 453 ptr_factory_.GetWeakPtr(),
434 *tunnel_auth_response, 454 *tunnel_auth_response,
435 http_proxy_socket->auth_controller())); 455 proxy_socket->GetAuthController()));
436 } 456 }
437 return ERR_IO_PENDING; 457 return ERR_IO_PENDING;
438 458
439 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: 459 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
440 MessageLoop::current()->PostTask( 460 MessageLoop::current()->PostTask(
441 FROM_HERE, 461 FROM_HERE,
442 base::Bind( 462 base::Bind(
443 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, 463 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback,
444 ptr_factory_.GetWeakPtr(), 464 ptr_factory_.GetWeakPtr(),
445 connection_->ssl_error_response_info().cert_request_info)); 465 connection_->ssl_error_response_info().cert_request_info));
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 request_info_.extra_headers, 746 request_info_.extra_headers,
727 request_info_.load_flags, 747 request_info_.load_flags,
728 request_info_.priority, 748 request_info_.priority,
729 session_, 749 session_,
730 proxy_info_, 750 proxy_info_,
731 ShouldForceSpdySSL(), 751 ShouldForceSpdySSL(),
732 want_spdy_over_npn, 752 want_spdy_over_npn,
733 server_ssl_config_, 753 server_ssl_config_,
734 proxy_ssl_config_, 754 proxy_ssl_config_,
735 net_log_, 755 net_log_,
736 num_streams_); 756 num_streams_,
757 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback,
758 ptr_factory_.GetWeakPtr()));
737 } else { 759 } else {
738 return InitSocketHandleForHttpRequest( 760 return InitSocketHandleForHttpRequest(
739 origin_url_, request_info_.extra_headers, request_info_.load_flags, 761 origin_url_, request_info_.extra_headers, request_info_.load_flags,
740 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(), 762 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(),
741 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_, 763 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_,
742 connection_.get(), io_callback_); 764 connection_.get(),
765 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback,
766 ptr_factory_.GetWeakPtr()),
767 io_callback_);
743 } 768 }
744 } 769 }
745 770
746 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { 771 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) {
747 if (IsPreconnecting()) { 772 if (IsPreconnecting()) {
748 DCHECK_EQ(OK, result); 773 DCHECK_EQ(OK, result);
749 return OK; 774 return OK;
750 } 775 }
751 776
752 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable 777 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 return false; 1245 return false;
1221 } 1246 }
1222 if (request_info_.method != "GET" && request_info_.method != "HEAD") { 1247 if (request_info_.method != "GET" && request_info_.method != "HEAD") {
1223 return false; 1248 return false;
1224 } 1249 }
1225 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( 1250 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining(
1226 origin_); 1251 origin_);
1227 } 1252 }
1228 1253
1229 } // namespace net 1254 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job.h ('k') | net/http/http_stream_factory_impl_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698