diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 18:46:27 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 18:46:27 +0000 |
commit | 3e221547889de746a6210b1549842f6875585151 (patch) | |
tree | ef565336f2e0a4b3e999d494531b198b25afdc03 /net | |
parent | b69277df648bcfce684dfe18e2f13073897fb195 (diff) | |
download | chromium_src-3e221547889de746a6210b1549842f6875585151.zip chromium_src-3e221547889de746a6210b1549842f6875585151.tar.gz chromium_src-3e221547889de746a6210b1549842f6875585151.tar.bz2 |
HTTP Cache: Apply all freshness tests to Partial content entries.
BUG=24057
TEST=unittest
Review URL: http://codereview.chromium.org/267122
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_cache.cc | 3 | ||||
-rw-r--r-- | net/http/http_response_headers.cc | 6 | ||||
-rw-r--r-- | net/http/http_response_headers_unittest.cc | 24 |
3 files changed, 29 insertions, 4 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index ded4565..856c41a 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -1099,6 +1099,9 @@ bool HttpCache::Transaction::RequiresValidation() { if (effective_load_flags_ & LOAD_VALIDATE_CACHE) return true; + if (response_.headers->response_code() == 206 && !enable_range_support_) + return true; + if (response_.headers->RequiresValidation( response_.request_time, response_.response_time, Time::Now())) return true; diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc index 4397939..9348006 100644 --- a/net/http/http_response_headers.cc +++ b/net/http/http_response_headers.cc @@ -840,9 +840,6 @@ TimeDelta HttpResponseHeaders::GetFreshnessLifetime( // there are cache-control directives or another header(s) that explicitly // allow it. // - // Since we do not support byte range requests yet, we exclude 206. See - // HttpCache::Transaction::ShouldPassThrough. - // // From RFC 2616 section 14.9.4: // // When the must-revalidate directive is present in a response received by @@ -852,7 +849,8 @@ TimeDelta HttpResponseHeaders::GetFreshnessLifetime( // time, if, based solely on the origin server's Expires or max-age value, // the cached response is stale.) // - if ((response_code_ == 200 || response_code_ == 203) && + if ((response_code_ == 200 || response_code_ == 203 || + response_code_ == 206) && !HasHeaderValue("cache-control", "must-revalidate")) { // TODO(darin): Implement a smarter heuristic. Time last_modified_value; diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index 448accb..d2ff378 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -715,6 +715,18 @@ TEST(HttpResponseHeadersTest, RequiresValidation) { "\n", false }, + { "HTTP/1.1 203 Non-Authoritative Information\n" + "date: Wed, 28 Nov 2007 00:40:11 GMT\n" + "last-modified: Wed, 27 Nov 2007 08:00:00 GMT\n" + "\n", + false + }, + { "HTTP/1.1 206 Partial Content\n" + "date: Wed, 28 Nov 2007 00:40:11 GMT\n" + "last-modified: Wed, 27 Nov 2007 08:00:00 GMT\n" + "\n", + false + }, // last-modified heuristic: modified recently { "HTTP/1.1 200 OK\n" "date: Wed, 28 Nov 2007 00:40:11 GMT\n" @@ -722,6 +734,18 @@ TEST(HttpResponseHeadersTest, RequiresValidation) { "\n", true }, + { "HTTP/1.1 203 Non-Authoritative Information\n" + "date: Wed, 28 Nov 2007 00:40:11 GMT\n" + "last-modified: Wed, 28 Nov 2007 00:40:10 GMT\n" + "\n", + true + }, + { "HTTP/1.1 206 Partial Content\n" + "date: Wed, 28 Nov 2007 00:40:11 GMT\n" + "last-modified: Wed, 28 Nov 2007 00:40:10 GMT\n" + "\n", + true + }, // cached permanent redirect { "HTTP/1.1 301 Moved Permanently\n" "\n", |