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

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
« net/http/http_request_headers.cc ('K') | « 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 84980)
+++ net/url_request/url_request_http_job.cc (working copy)
@@ -13,6 +13,7 @@
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/rand_util.h"
+#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/time.h"
#include "net/base/cert_status_flags.h"
@@ -27,6 +28,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 +56,14 @@
namespace {
+std::string BuildIssuerForMac(const std::string& source) {
+ // TODO(abarth): The issuer has had its scheme doctored!
+ GURL issuer(source);
+ // Notice that we include the port even if the port is the default port.
+ // TODO(abarth): We're geting the wrong port number here.
+ return issuer.host() + ":" + base::IntToString(issuer.IntPort());
cbentzel 2011/05/13 14:05:45 You can just use GetHostAndPort from net_util.h he
+}
+
class HTTPSProberDelegateImpl : public HTTPSProberDelegate {
public:
HTTPSProberDelegateImpl(const std::string& host, int max_age,
@@ -588,17 +598,49 @@
}
}
+void URLRequestHttpJob::AddAuthorizationHeader(
cbentzel 2011/05/13 14:05:45 You could make a static/top-level function which p
abarth-chromium 2011/05/13 17:36:23 Yeah, that makes unit testing at this layer slight
+ const std::vector<CookieStore::CookieInfo>& cookie_infos) {
+ 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.IntPort();
cbentzel 2011/05/13 14:05:45 You'll want to use EffectiveIntPort here to captur
abarth-chromium 2011/05/13 17:36:23 Done.
+
+ for (size_t i = 0; i < cookie_infos.size(); ++i) {
+ const CookieStore::CookieInfo& cookie_info = cookie_infos[i];
+ if (cookie_info.mac_key.empty() || cookie_info.mac_algorithm.empty())
cbentzel 2011/05/13 14:05:45 I would remove the empty string tests here, since
abarth-chromium 2011/05/13 17:36:23 Done.
+ continue;
+ HttpMacSignature signature;
+ if (!signature.AddStateInfo(cookie_info.name,
+ cookie_info.mac_key,
+ cookie_info.mac_algorithm,
+ BuildIssuerForMac(cookie_info.source))) {
+ 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.
cbentzel 2011/05/13 14:05:45 I thought you were planning to support multiple Au
+ }
+}
+
void URLRequestHttpJob::OnCanGetCookiesCompleted(bool allow) {
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);
}
// We may have been canceled within CanGetCookies.
if (GetStatus().is_success()) {
« net/http/http_request_headers.cc ('K') | « 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