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

Unified Diff: net/url_request/url_request_http_job.cc

Issue 4630001: Implement Origin cookies. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_http_job.cc
===================================================================
--- net/url_request/url_request_http_job.cc (revision 65294)
+++ net/url_request/url_request_http_job.cc (working copy)
@@ -438,6 +438,21 @@
transaction_->StopCaching();
}
+void URLRequestHttpJob::AddCookies(bool origin_cookies) {
+ net::CookieOptions options;
+ options.set_include_httponly();
+ options.set_read_origin(origin_cookies);
+
+ std::string cookies =
+ request_->context()->cookie_store()->GetCookiesWithOptions(
+ request_->url(), options);
+ if (cookies.empty())
+ return;
+ const std::string& header_name = origin_cookies ?
+ net::HttpRequestHeaders::kOriginCookie : net::HttpRequestHeaders::kCookie;
+ request_info_.extra_headers.SetHeader(header_name, cookies);
+}
+
void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) {
// If the request was destroyed, then there is no more work to do.
if (request_ && request_->delegate()) {
@@ -445,15 +460,8 @@
request_->delegate()->OnGetCookies(request_, true);
} else if (policy == net::OK && request_->context()->cookie_store()) {
request_->delegate()->OnGetCookies(request_, false);
- net::CookieOptions options;
- options.set_include_httponly();
- std::string cookies =
- request_->context()->cookie_store()->GetCookiesWithOptions(
- request_->url(), options);
- if (!cookies.empty()) {
- request_info_.extra_headers.SetHeader(
- net::HttpRequestHeaders::kCookie, cookies);
- }
+ AddCookies(false);
+ AddCookies(true);
}
// We may have been canceled within OnGetCookies.
if (GetStatus().is_success()) {
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698