summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_http_job.cc14
-rw-r--r--net/url_request/url_request_unittest.cc7
2 files changed, 12 insertions, 9 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 15dafe6..8f2412e 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -437,9 +437,9 @@ void URLRequestHttpJob::StopCaching() {
void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) {
// If the request was destroyed, then there is no more work to do.
if (request_ && request_->delegate()) {
- if (policy != net::OK) {
+ if (policy == net::ERR_ACCESS_DENIED) {
request_->delegate()->OnGetCookiesBlocked(request_);
- } else if (request_->context()->cookie_store()) {
+ } else if (policy == net::OK && request_->context()->cookie_store()) {
net::CookieOptions options;
options.set_include_httponly();
std::string cookies =
@@ -462,10 +462,10 @@ void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) {
void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) {
// If the request was destroyed, then there is no more work to do.
if (request_ && request_->delegate()) {
- if (policy != net::OK &&
- policy != net::OK_FOR_SESSION_ONLY) {
+ if (policy == net::ERR_ACCESS_DENIED) {
request_->delegate()->OnSetCookieBlocked(request_);
- } else if (request_->context()->cookie_store()) {
+ } else if ((policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) &&
+ request_->context()->cookie_store()) {
// OK to save the current response cookie now.
net::CookieOptions options;
options.set_include_httponly();
@@ -705,7 +705,7 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() {
int policy = net::OK;
if (request_info_.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) {
- policy = net::ERR_ACCESS_DENIED;
+ policy = net::ERR_FAILED;
} else if (request_->context()->cookie_policy()) {
policy = request_->context()->cookie_policy()->CanGetCookies(
request_->url(),
@@ -751,7 +751,7 @@ void URLRequestHttpJob::SaveNextCookie() {
int policy = net::OK;
if (request_info_.load_flags & net::LOAD_DO_NOT_SAVE_COOKIES) {
- policy = net::ERR_ACCESS_DENIED;
+ policy = net::ERR_FAILED;
} else if (request_->context()->cookie_policy()) {
policy = request_->context()->cookie_policy()->CanSetCookie(
request_->url(),
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 16f4b3f..a1f0cf5e 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -1270,7 +1270,9 @@ TEST_F(URLRequestTest, DoNotSendCookies) {
EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
== std::string::npos);
- EXPECT_EQ(1, d.blocked_get_cookies_count());
+
+ // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookiesBlocked.
+ EXPECT_EQ(0, d.blocked_get_cookies_count());
EXPECT_EQ(0, d.blocked_set_cookie_count());
}
}
@@ -1305,8 +1307,9 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
MessageLoop::current()->Run();
+ // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookieBlocked.
EXPECT_EQ(0, d.blocked_get_cookies_count());
- EXPECT_EQ(2, d.blocked_set_cookie_count());
+ EXPECT_EQ(0, d.blocked_set_cookie_count());
}
// Verify the cookies weren't saved or updated.