| 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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 303 |
| 304 // sanity checks: | 304 // sanity checks: |
| 305 DCHECK(proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH || | 305 DCHECK(proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH || |
| 306 server_auth_state_ == net::AUTH_STATE_NEED_AUTH); | 306 server_auth_state_ == net::AUTH_STATE_NEED_AUTH); |
| 307 DCHECK(response_info_->headers->response_code() == 401 || | 307 DCHECK(response_info_->headers->response_code() == 401 || |
| 308 response_info_->headers->response_code() == 407); | 308 response_info_->headers->response_code() == 407); |
| 309 | 309 |
| 310 *result = response_info_->auth_challenge; | 310 *result = response_info_->auth_challenge; |
| 311 } | 311 } |
| 312 | 312 |
| 313 void URLRequestHttpJob::SetAuth(const std::wstring& username, | 313 void URLRequestHttpJob::SetAuth(const string16& username, |
| 314 const std::wstring& password) { | 314 const string16& password) { |
| 315 DCHECK(transaction_.get()); | 315 DCHECK(transaction_.get()); |
| 316 | 316 |
| 317 // Proxy gets set first, then WWW. | 317 // Proxy gets set first, then WWW. |
| 318 if (proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH) { | 318 if (proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH) { |
| 319 proxy_auth_state_ = net::AUTH_STATE_HAVE_AUTH; | 319 proxy_auth_state_ = net::AUTH_STATE_HAVE_AUTH; |
| 320 } else { | 320 } else { |
| 321 DCHECK(server_auth_state_ == net::AUTH_STATE_NEED_AUTH); | 321 DCHECK(server_auth_state_ == net::AUTH_STATE_NEED_AUTH); |
| 322 server_auth_state_ = net::AUTH_STATE_HAVE_AUTH; | 322 server_auth_state_ = net::AUTH_STATE_HAVE_AUTH; |
| 323 } | 323 } |
| 324 | 324 |
| 325 RestartTransactionWithAuth(username, password); | 325 RestartTransactionWithAuth(username, password); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void URLRequestHttpJob::RestartTransactionWithAuth( | 328 void URLRequestHttpJob::RestartTransactionWithAuth( |
| 329 const std::wstring& username, | 329 const string16& username, |
| 330 const std::wstring& password) { | 330 const string16& password) { |
| 331 username_ = username; | 331 username_ = username; |
| 332 password_ = password; | 332 password_ = password; |
| 333 | 333 |
| 334 // These will be reset in OnStartCompleted. | 334 // These will be reset in OnStartCompleted. |
| 335 response_info_ = NULL; | 335 response_info_ = NULL; |
| 336 response_cookies_.clear(); | 336 response_cookies_.clear(); |
| 337 | 337 |
| 338 // Update the cookies, since the cookie store may have been updated from the | 338 // Update the cookies, since the cookie store may have been updated from the |
| 339 // headers in the 401/407. Since cookies were already appended to | 339 // headers in the 401/407. Since cookies were already appended to |
| 340 // extra_headers, we need to strip them out before adding them again. | 340 // extra_headers, we need to strip them out before adding them again. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // Resolve suggested URL relative to request url. | 589 // Resolve suggested URL relative to request url. |
| 590 sdch_dictionary_url_ = request_info_.url.Resolve(url_text); | 590 sdch_dictionary_url_ = request_info_.url.Resolve(url_text); |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 | 593 |
| 594 // The HTTP transaction may be restarted several times for the purposes | 594 // The HTTP transaction may be restarted several times for the purposes |
| 595 // of sending authorization information. Each time it restarts, we get | 595 // of sending authorization information. Each time it restarts, we get |
| 596 // notified of the headers completion so that we can update the cookie store. | 596 // notified of the headers completion so that we can update the cookie store. |
| 597 if (transaction_->IsReadyToRestartForAuth()) { | 597 if (transaction_->IsReadyToRestartForAuth()) { |
| 598 DCHECK(!response_info_->auth_challenge.get()); | 598 DCHECK(!response_info_->auth_challenge.get()); |
| 599 RestartTransactionWithAuth(std::wstring(), std::wstring()); | 599 RestartTransactionWithAuth(string16(), string16()); |
| 600 return; | 600 return; |
| 601 } | 601 } |
| 602 | 602 |
| 603 URLRequestJob::NotifyHeadersComplete(); | 603 URLRequestJob::NotifyHeadersComplete(); |
| 604 } | 604 } |
| 605 | 605 |
| 606 void URLRequestHttpJob::DestroyTransaction() { | 606 void URLRequestHttpJob::DestroyTransaction() { |
| 607 DCHECK(transaction_.get()); | 607 DCHECK(transaction_.get()); |
| 608 | 608 |
| 609 transaction_.reset(); | 609 transaction_.reset(); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 HTTPSProberDelegate* delegate = | 910 HTTPSProberDelegate* delegate = |
| 911 new HTTPSProberDelegate(request_info_.url.host(), max_age, | 911 new HTTPSProberDelegate(request_info_.url.host(), max_age, |
| 912 include_subdomains, | 912 include_subdomains, |
| 913 ctx->transport_security_state()); | 913 ctx->transport_security_state()); |
| 914 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), | 914 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), |
| 915 delegate)) { | 915 delegate)) { |
| 916 delete delegate; | 916 delete delegate; |
| 917 } | 917 } |
| 918 } | 918 } |
| 919 } | 919 } |
| OLD | NEW |