summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache_transaction.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 01:13:36 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 01:13:36 +0000
commitdbd39fbe246f0234c3d583ac52c3d9351acc9393 (patch)
tree7f8e89e1a1b8a8fb8c6cfd2a569cc00c4d272ca7 /net/http/http_cache_transaction.cc
parent5cfae741680e577a27ad993fb7508c8c156ce331 (diff)
downloadchromium_src-dbd39fbe246f0234c3d583ac52c3d9351acc9393.zip
chromium_src-dbd39fbe246f0234c3d583ac52c3d9351acc9393.tar.gz
chromium_src-dbd39fbe246f0234c3d583ac52c3d9351acc9393.tar.bz2
Http cache: Avoid resuming (and keeping) truncated entries
if the server doesn't provide a strong validator. We require: - A strong etag or a strong last modified date. - The total Content length. - Lack of an explicit rejection of ranges (Accept-ranges: none) This aligns better with the conditions used by Firefox. BUG=30220, b/2329250 TEST=unittests Review URL: http://codereview.chromium.org/517043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_transaction.cc')
-rw-r--r--net/http/http_cache_transaction.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index b829623..32808e8 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -548,6 +548,11 @@ bool HttpCache::Transaction::AddTruncatedFlag() {
if (!entry_->disk_entry->GetDataSize(kResponseContentIndex))
return false;
+ if (response_.headers->GetContentLength() <= 0 ||
+ response_.headers->HasHeaderValue("Accept-Ranges", "none") ||
+ !response_.headers->HasStrongValidators())
+ return false;
+
truncated_ = true;
target_state_ = STATE_NONE;
next_state_ = STATE_CACHE_WRITE_TRUNCATED_RESPONSE;
@@ -1142,7 +1147,7 @@ bool HttpCache::Transaction::ConditionalizeRequest() {
custom_request_->extra_headers.append("\r\n");
// For byte-range requests, make sure that we use only one way to validate
// the request.
- if (partial_.get())
+ if (partial_.get() && !partial_->IsCurrentRangeCached())
return true;
}
@@ -1224,7 +1229,10 @@ bool HttpCache::Transaction::ValidatePartialResponse(
return true;
}
- // 304 is not expected here, but we'll spare the entry.
+ // 304 is not expected here, but we'll spare the entry (unless it was
+ // truncated).
+ if (truncated_)
+ failure = true;
}
if (failure) {