diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 22:05:54 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 22:05:54 +0000 |
commit | 7eab0d22638954a4539a408c1b44082cb78f7a7d (patch) | |
tree | 82c3a82573d5a329c8ac76123e61880f6073c063 /net/http/http_response_headers.cc | |
parent | 1405220aad5d0885a3f583e95d9a96e76455b1c7 (diff) | |
download | chromium_src-7eab0d22638954a4539a408c1b44082cb78f7a7d.zip chromium_src-7eab0d22638954a4539a408c1b44082cb78f7a7d.tar.gz chromium_src-7eab0d22638954a4539a408c1b44082cb78f7a7d.tar.bz2 |
Http Cache: More unit tests for byte range support.
BUG=b/2071330
TEST=unittests
Review URL: http://codereview.chromium.org/267101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_response_headers.cc')
-rw-r--r-- | net/http/http_response_headers.cc | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc index 9cbd72f..4397939 100644 --- a/net/http/http_response_headers.cc +++ b/net/http/http_response_headers.cc @@ -765,7 +765,6 @@ bool HttpResponseHeaders::IsRedirect(std::string* location) const { bool HttpResponseHeaders::RequiresValidation(const Time& request_time, const Time& response_time, const Time& current_time) const { - TimeDelta lifetime = GetFreshnessLifetime(response_time); if (lifetime == TimeDelta()) @@ -1032,6 +1031,7 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position, int64* instance_length) const { void* iter = NULL; std::string content_range_spec; + *first_byte_position = *last_byte_position = *instance_length = -1; if (!EnumerateHeader(&iter, "content-range", &content_range_spec)) return false; @@ -1069,11 +1069,8 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position, // Parse the byte-range-resp-spec part. std::string byte_range_resp_spec(byte_range_resp_spec_begin, byte_range_resp_spec_end); - // If byte-range-resp-spec == "*". - if (LowerCaseEqualsASCII(byte_range_resp_spec, "*")) { - *first_byte_position = -1; - *last_byte_position = -1; - } else { + // If byte-range-resp-spec != "*". + if (!LowerCaseEqualsASCII(byte_range_resp_spec, "*")) { size_t minus_position = byte_range_resp_spec.find('-'); if (minus_position != std::string::npos) { // Obtain first-byte-pos. @@ -1097,9 +1094,11 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position, ok &= StringToInt64( std::string(last_byte_pos_begin, last_byte_pos_end), last_byte_position); - if (!ok || - *first_byte_position < 0 || - *last_byte_position < 0 || + if (!ok) { + *first_byte_position = *last_byte_position = -1; + return false; + } + if (*first_byte_position < 0 || *last_byte_position < 0 || *first_byte_position > *last_byte_position) return false; } else { @@ -1116,17 +1115,20 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position, HttpUtil::TrimLWS(&instance_length_begin, &instance_length_end); if (LowerCaseEqualsASCII(instance_length_begin, instance_length_end, "*")) { - *instance_length = -1; + return false; } else if (!StringToInt64( std::string(instance_length_begin, instance_length_end), instance_length)) { - return false; - } else if (*instance_length < 0 || - *instance_length < - *last_byte_position - *first_byte_position + 1) { + *instance_length = -1; return false; } + // We have all the values; let's verify that they make sense for a 206 + // response. + if (*first_byte_position < 0 || *last_byte_position < 0 || + *instance_length < 0 || *instance_length - 1 < *last_byte_position) + return false; + return true; } |