diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request_context.h | 15 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.cc | 8 |
2 files changed, 12 insertions, 11 deletions
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h index 5eac06e..b0204ce 100644 --- a/net/url_request/url_request_context.h +++ b/net/url_request/url_request_context.h @@ -105,16 +105,17 @@ class URLRequestContext : referrer_charset_ = charset; } - // Called for each cookie returning for the given request. A pointer to - // the cookie is passed so that it can be modified. Returns true if the - // cookie was not dropped (it could still be modified though). - virtual bool InterceptCookie(const URLRequest* request, std::string* cookie) { + // Called before adding cookies to requests. Returns true if cookie can + // be added to the request. The cookie might still be modified though. + virtual bool InterceptRequestCookies(const URLRequest* request, + const std::string& cookies) const { return true; } - // Called before adding cookies to sent requests. Allows overriding - // requests to block sending of cookies. - virtual bool AllowSendingCookies(const URLRequest* request) const { + // Called before adding cookies from respones to the cookie monster. Returns + // true if the cookie can be added. The cookie might still be modified though. + virtual bool InterceptResponseCookie(const URLRequest* request, + const std::string& cookie) const { return true; } diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 93f6b5b..4b665be 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -647,8 +647,7 @@ void URLRequestHttpJob::AddExtraHeaders() { URLRequestContext* context = request_->context(); if (context) { - if (context->AllowSendingCookies(request_)) - request_info_.extra_headers += AssembleRequestCookies(); + request_info_.extra_headers += AssembleRequestCookies(); // Only add default Accept-Language and Accept-Charset if the request // didn't have them specified. @@ -675,7 +674,8 @@ std::string URLRequestHttpJob::AssembleRequestCookies() { options.set_include_httponly(); std::string cookies = request_->context()->cookie_store()-> GetCookiesWithOptions(request_->url(), options); - if (!cookies.empty()) + if (context->InterceptRequestCookies(request_, cookies) && + !cookies.empty()) return "Cookie: " + cookies + "\r\n"; } } @@ -691,7 +691,7 @@ void URLRequestHttpJob::FetchResponseCookies() { void* iter = NULL; while (response_info_->headers->EnumerateHeader(&iter, name, &value)) - if (request_->context()->InterceptCookie(request_, &value)) + if (request_->context()->InterceptResponseCookie(request_, value)) response_cookies_.push_back(value); } |