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

Unified Diff: net/url_request/url_request_http_job.cc

Issue 6969050: MAC Cookies (patch 4 of N) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months 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/http/http_request_headers.cc ('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 85283)
+++ net/url_request/url_request_http_job.cc (working copy)
@@ -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 {
+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 @@
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()) {
« no previous file with comments | « net/http/http_request_headers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698