| 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 444 } |
| 445 | 445 |
| 446 void URLRequestHttpJob::StopCaching() { | 446 void URLRequestHttpJob::StopCaching() { |
| 447 if (transaction_.get()) | 447 if (transaction_.get()) |
| 448 transaction_->StopCaching(); | 448 transaction_->StopCaching(); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { | 451 void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { |
| 452 // If the request was destroyed, then there is no more work to do. | 452 // If the request was destroyed, then there is no more work to do. |
| 453 if (request_ && request_->delegate()) { | 453 if (request_ && request_->delegate()) { |
| 454 if (policy == net::ERR_ACCESS_DENIED) { | 454 if (request_->context()->cookie_store()) { |
| 455 request_->delegate()->OnGetCookies(request_, true); | 455 if (policy == net::ERR_ACCESS_DENIED) { |
| 456 } else if (policy == net::OK && request_->context()->cookie_store()) { | 456 request_->delegate()->OnGetCookies(request_, true); |
| 457 request_->delegate()->OnGetCookies(request_, false); | 457 } else if (policy == net::OK) { |
| 458 net::CookieOptions options; | 458 request_->delegate()->OnGetCookies(request_, false); |
| 459 options.set_include_httponly(); | 459 net::CookieOptions options; |
| 460 std::string cookies = | 460 options.set_include_httponly(); |
| 461 request_->context()->cookie_store()->GetCookiesWithOptions( | 461 std::string cookies = |
| 462 request_->url(), options); | 462 request_->context()->cookie_store()->GetCookiesWithOptions( |
| 463 if (!cookies.empty()) { | 463 request_->url(), options); |
| 464 request_info_.extra_headers.SetHeader( | 464 if (!cookies.empty()) { |
| 465 net::HttpRequestHeaders::kCookie, cookies); | 465 request_info_.extra_headers.SetHeader( |
| 466 net::HttpRequestHeaders::kCookie, cookies); |
| 467 } |
| 466 } | 468 } |
| 467 } | 469 } |
| 468 // We may have been canceled within OnGetCookies. | 470 // We may have been canceled within OnGetCookies. |
| 469 if (GetStatus().is_success()) { | 471 if (GetStatus().is_success()) { |
| 470 StartTransaction(); | 472 StartTransaction(); |
| 471 } else { | 473 } else { |
| 472 NotifyCanceled(); | 474 NotifyCanceled(); |
| 473 } | 475 } |
| 474 } | 476 } |
| 475 Release(); // Balance AddRef taken in AddCookieHeaderAndStart | 477 Release(); // Balance AddRef taken in AddCookieHeaderAndStart |
| 476 } | 478 } |
| 477 | 479 |
| 478 void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) { | 480 void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) { |
| 479 // If the request was destroyed, then there is no more work to do. | 481 // If the request was destroyed, then there is no more work to do. |
| 480 if (request_ && request_->delegate()) { | 482 if (request_ && request_->delegate()) { |
| 481 if (policy == net::ERR_ACCESS_DENIED) { | 483 if (request_->context()->cookie_store()) { |
| 482 request_->delegate()->OnSetCookie( | 484 if (policy == net::ERR_ACCESS_DENIED) { |
| 483 request_, | 485 request_->delegate()->OnSetCookie( |
| 484 response_cookies_[response_cookies_save_index_], | 486 request_, |
| 485 net::CookieOptions(), | 487 response_cookies_[response_cookies_save_index_], |
| 486 true); | 488 net::CookieOptions(), |
| 487 } else if ((policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) && | 489 true); |
| 488 request_->context()->cookie_store()) { | 490 } else if (policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) { |
| 489 // OK to save the current response cookie now. | 491 // OK to save the current response cookie now. |
| 490 net::CookieOptions options; | 492 net::CookieOptions options; |
| 491 options.set_include_httponly(); | 493 options.set_include_httponly(); |
| 492 if (policy == net::OK_FOR_SESSION_ONLY) | 494 if (policy == net::OK_FOR_SESSION_ONLY) |
| 493 options.set_force_session(); | 495 options.set_force_session(); |
| 494 request_->context()->cookie_store()->SetCookieWithOptions( | 496 request_->context()->cookie_store()->SetCookieWithOptions( |
| 495 request_->url(), response_cookies_[response_cookies_save_index_], | 497 request_->url(), response_cookies_[response_cookies_save_index_], |
| 496 options); | 498 options); |
| 497 request_->delegate()->OnSetCookie( | 499 request_->delegate()->OnSetCookie( |
| 498 request_, | 500 request_, |
| 499 response_cookies_[response_cookies_save_index_], | 501 response_cookies_[response_cookies_save_index_], |
| 500 options, | 502 options, |
| 501 false); | 503 false); |
| 504 } |
| 502 } | 505 } |
| 503 response_cookies_save_index_++; | 506 response_cookies_save_index_++; |
| 504 // We may have been canceled within OnSetCookie. | 507 // We may have been canceled within OnSetCookie. |
| 505 if (GetStatus().is_success()) { | 508 if (GetStatus().is_success()) { |
| 506 SaveNextCookie(); | 509 SaveNextCookie(); |
| 507 } else { | 510 } else { |
| 508 NotifyCanceled(); | 511 NotifyCanceled(); |
| 509 } | 512 } |
| 510 } | 513 } |
| 511 Release(); // Balance AddRef taken in SaveNextCookie | 514 Release(); // Balance AddRef taken in SaveNextCookie |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 HTTPSProberDelegate* delegate = | 946 HTTPSProberDelegate* delegate = |
| 944 new HTTPSProberDelegate(request_info_.url.host(), max_age, | 947 new HTTPSProberDelegate(request_info_.url.host(), max_age, |
| 945 include_subdomains, | 948 include_subdomains, |
| 946 ctx->transport_security_state()); | 949 ctx->transport_security_state()); |
| 947 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), | 950 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), |
| 948 delegate)) { | 951 delegate)) { |
| 949 delete delegate; | 952 delete delegate; |
| 950 } | 953 } |
| 951 } | 954 } |
| 952 } | 955 } |
| OLD | NEW |