| OLD | NEW |
| 1 // Copyright (c) 2006-2009 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" |
| 11 #include "base/file_version_info.h" | 11 #include "base/file_version_info.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "net/base/cert_status_flags.h" | 15 #include "net/base/cert_status_flags.h" |
| 16 #include "net/base/cookie_policy.h" |
| 16 #include "net/base/filter.h" | 17 #include "net/base/filter.h" |
| 17 #include "net/base/https_prober.h" | 18 #include "net/base/https_prober.h" |
| 18 #include "net/base/transport_security_state.h" | 19 #include "net/base/transport_security_state.h" |
| 19 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 22 #include "net/base/sdch_manager.h" | 23 #include "net/base/sdch_manager.h" |
| 23 #include "net/base/ssl_cert_request_info.h" | 24 #include "net/base/ssl_cert_request_info.h" |
| 24 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| 25 #include "net/http/http_response_info.h" | 26 #include "net/http/http_response_info.h" |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 505 |
| 505 response_info_ = transaction_->GetResponseInfo(); | 506 response_info_ = transaction_->GetResponseInfo(); |
| 506 | 507 |
| 507 // Save boolean, as we'll need this info at destruction time, and filters may | 508 // Save boolean, as we'll need this info at destruction time, and filters may |
| 508 // also need this info. | 509 // also need this info. |
| 509 is_cached_content_ = response_info_->was_cached; | 510 is_cached_content_ = response_info_->was_cached; |
| 510 | 511 |
| 511 // Get the Set-Cookie values, and send them to our cookie database. | 512 // Get the Set-Cookie values, and send them to our cookie database. |
| 512 if (!(request_info_.load_flags & net::LOAD_DO_NOT_SAVE_COOKIES)) { | 513 if (!(request_info_.load_flags & net::LOAD_DO_NOT_SAVE_COOKIES)) { |
| 513 URLRequestContext* ctx = request_->context(); | 514 URLRequestContext* ctx = request_->context(); |
| 514 if (ctx && ctx->cookie_store() && | 515 if (ctx && ctx->cookie_store() && ctx->cookie_policy() && |
| 515 ctx->cookie_policy()->CanSetCookie( | 516 ctx->cookie_policy()->CanSetCookie( |
| 516 request_->url(), request_->first_party_for_cookies())) { | 517 request_->url(), request_->first_party_for_cookies())) { |
| 517 FetchResponseCookies(); | 518 FetchResponseCookies(); |
| 518 net::CookieOptions options; | 519 net::CookieOptions options; |
| 519 options.set_include_httponly(); | 520 options.set_include_httponly(); |
| 520 ctx->cookie_store()->SetCookiesWithOptions(request_->url(), | 521 ctx->cookie_store()->SetCookiesWithOptions(request_->url(), |
| 521 response_cookies_, | 522 response_cookies_, |
| 522 options); | 523 options); |
| 523 } | 524 } |
| 524 } | 525 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 } | 661 } |
| 661 } | 662 } |
| 662 | 663 |
| 663 std::string URLRequestHttpJob::AssembleRequestCookies() { | 664 std::string URLRequestHttpJob::AssembleRequestCookies() { |
| 664 if (request_info_.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) | 665 if (request_info_.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) |
| 665 return std::string(); | 666 return std::string(); |
| 666 | 667 |
| 667 URLRequestContext* context = request_->context(); | 668 URLRequestContext* context = request_->context(); |
| 668 if (context) { | 669 if (context) { |
| 669 // Add in the cookie header. TODO might we need more than one header? | 670 // Add in the cookie header. TODO might we need more than one header? |
| 670 if (context->cookie_store() && | 671 if (context->cookie_store() && context->cookie_policy() && |
| 671 context->cookie_policy()->CanGetCookies( | 672 context->cookie_policy()->CanGetCookies( |
| 672 request_->url(), request_->first_party_for_cookies())) { | 673 request_->url(), request_->first_party_for_cookies())) { |
| 673 net::CookieOptions options; | 674 net::CookieOptions options; |
| 674 options.set_include_httponly(); | 675 options.set_include_httponly(); |
| 675 std::string cookies = request_->context()->cookie_store()-> | 676 std::string cookies = request_->context()->cookie_store()-> |
| 676 GetCookiesWithOptions(request_->url(), options); | 677 GetCookiesWithOptions(request_->url(), options); |
| 677 if (context->InterceptRequestCookies(request_, cookies) && | 678 if (context->InterceptRequestCookies(request_, cookies) && |
| 678 !cookies.empty()) | 679 !cookies.empty()) |
| 679 return "Cookie: " + cookies + "\r\n"; | 680 return "Cookie: " + cookies + "\r\n"; |
| 680 } | 681 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 net::HTTPSProberDelegate* delegate = | 811 net::HTTPSProberDelegate* delegate = |
| 811 new HTTPSProberDelegate(request_info_.url.host(), max_age, | 812 new HTTPSProberDelegate(request_info_.url.host(), max_age, |
| 812 include_subdomains, | 813 include_subdomains, |
| 813 ctx->transport_security_state()); | 814 ctx->transport_security_state()); |
| 814 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), | 815 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), |
| 815 delegate)) { | 816 delegate)) { |
| 816 delete delegate; | 817 delete delegate; |
| 817 } | 818 } |
| 818 } | 819 } |
| 819 } | 820 } |
| OLD | NEW |