diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 01:13:36 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 01:13:36 +0000 |
commit | dbd39fbe246f0234c3d583ac52c3d9351acc9393 (patch) | |
tree | 7f8e89e1a1b8a8fb8c6cfd2a569cc00c4d272ca7 /net/http/partial_data.cc | |
parent | 5cfae741680e577a27ad993fb7508c8c156ce331 (diff) | |
download | chromium_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/partial_data.cc')
-rw-r--r-- | net/http/partial_data.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/net/http/partial_data.cc b/net/http/partial_data.cc index 0ef7f6b..f727699 100644 --- a/net/http/partial_data.cc +++ b/net/http/partial_data.cc @@ -130,9 +130,16 @@ bool PartialData::UpdateFromStoredHeaders(const HttpResponseHeaders* headers, if (byte_range_.IsValid()) return false; + // Now we avoid resume if there is no content length, but that was not + // always the case so double check here. + int64 total_length = headers->GetContentLength(); + if (total_length <= 0 || !headers->HasStrongValidators()) + return false; + truncated_ = true; sparse_entry_ = false; byte_range_.set_first_byte_position(entry->GetDataSize(kDataStream)); + resource_size_ = total_length; current_range_start_ = 0; return true; } @@ -144,12 +151,11 @@ bool PartialData::UpdateFromStoredHeaders(const HttpResponseHeaders* headers, return true; } - std::string length_value; - if (!headers->GetNormalizedHeader(kLengthHeader, &length_value)) + int64 length_value = headers->GetContentLength(); + if (length_value <= 0) return false; // We must have stored the resource length. - if (!StringToInt64(length_value, &resource_size_) || !resource_size_) - return false; + resource_size_ = length_value; // Make sure that this is really a sparse entry. int64 n; @@ -214,6 +220,11 @@ bool PartialData::ResponseHeadersOK(const HttpResponseHeaders* headers) { return false; } + if (truncated_) { + if (!byte_range_.HasLastBytePosition()) + byte_range_.set_last_byte_position(end); + } + if (start != current_range_start_) return false; |