diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 20:06:48 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 20:06:48 +0000 |
commit | 87c99b6ad49f48645399cbb2a85bb281859c6795 (patch) | |
tree | cf7b4e06b4ca3be1c837aeb2ded63640e38541ef /net/url_request/url_request_http_job.cc | |
parent | bbbe5d7dd70dabe0d728e789326879e02f63d040 (diff) | |
download | chromium_src-87c99b6ad49f48645399cbb2a85bb281859c6795.zip chromium_src-87c99b6ad49f48645399cbb2a85bb281859c6795.tar.gz chromium_src-87c99b6ad49f48645399cbb2a85bb281859c6795.tar.bz2 |
MAC Cookies (patch 4 of N)
Wire up the pieces of MAC cookies (behind the --enable-mac-cookies flag).
Also, update the syntax of the header now that issuer has been removed and the
timestamp and nonce are combined into one field.
Review URL: http://codereview.chromium.org/6969050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_http_job.cc')
-rw-r--r-- | net/url_request/url_request_http_job.cc | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 55f6028..510a68d 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -27,6 +27,7 @@ #include "net/base/ssl_cert_request_info.h" #include "net/base/ssl_config_service.h" #include "net/base/transport_security_state.h" +#include "net/http/http_mac_signature.h" #include "net/http/http_request_headers.h" #include "net/http/http_response_headers.h" #include "net/http/http_response_info.h" @@ -54,6 +55,30 @@ namespace net { namespace { +void AddAuthorizationHeader( + const std::vector<CookieStore::CookieInfo>& cookie_infos, + HttpRequestInfo* request_info) { + const GURL& url = request_info->url; + const std::string& method = request_info->method; + std::string request_uri = HttpUtil::PathForRequest(url); + const std::string& host = url.host(); + int port = url.EffectiveIntPort(); + for (size_t i = 0; i < cookie_infos.size(); ++i) { + HttpMacSignature signature; + if (!signature.AddStateInfo(cookie_infos[i].name, + cookie_infos[i].mac_key, + cookie_infos[i].mac_algorithm)) { + continue; + } + if (!signature.AddHttpInfo(method, request_uri, host, port)) + continue; + request_info->extra_headers.SetHeader( + HttpRequestHeaders::kAuthorization, + signature.GenerateAuthorizationHeader()); + return; // Only add the first valid header. + } +} + class HTTPSProberDelegateImpl : public HTTPSProberDelegate { public: HTTPSProberDelegateImpl(const std::string& host, int max_age, @@ -440,13 +465,16 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() { if (request_->context()->cookie_store() && allow) { CookieOptions options; options.set_include_httponly(); - std::string cookies = - request_->context()->cookie_store()->GetCookiesWithOptions( - request_->url(), options); - if (!cookies.empty()) { + std::string cookie_line; + std::vector<CookieStore::CookieInfo> cookie_infos; + request_->context()->cookie_store()->GetCookiesWithInfo( + request_->url(), options, &cookie_line, &cookie_infos); + if (!cookie_line.empty()) { request_info_.extra_headers.SetHeader( - HttpRequestHeaders::kCookie, cookies); + HttpRequestHeaders::kCookie, cookie_line); } + if (URLRequest::AreMacCookiesEnabled()) + AddAuthorizationHeader(cookie_infos, &request_info_); } // We may have been canceled within CanGetCookies. if (GetStatus().is_success()) { |