summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-27 04:46:32 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-27 04:46:32 +0000
commit93e784417f9c2f3878086f6345ae1c4272b427d6 (patch)
tree145943e9369f8ba0c1c7bf9eb47d1904e3aaa663 /net/http
parent45c9ad071c37ca217da9d34d6bec3fd217bc015d (diff)
downloadchromium_src-93e784417f9c2f3878086f6345ae1c4272b427d6.zip
chromium_src-93e784417f9c2f3878086f6345ae1c4272b427d6.tar.gz
chromium_src-93e784417f9c2f3878086f6345ae1c4272b427d6.tar.bz2
Http cache: Handle byte range requests when there is no cache entry.
BUG=25873 TEST=unittest Review URL: http://codereview.chromium.org/330026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30165 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache.cc3
-rw-r--r--net/http/http_cache_unittest.cc13
2 files changed, 16 insertions, 0 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index f9cdd5e..f9ea07d 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -1214,6 +1214,9 @@ bool HttpCache::Transaction::ValidatePartialResponse(
int response_code = headers->response_code();
bool partial_content = enable_range_support_ ? response_code == 206 : false;
+ if (!entry_)
+ return false;
+
if (invalid_range_) {
// We gave up trying to match this request with the stored data. If the
// server is ok with the request, delete the entry, otherwise just ignore
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 1206598..ce64f93 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -2671,6 +2671,19 @@ TEST(HttpCache, RangeGET_LargeValues) {
RemoveMockTransaction(&kRangeGET_TransactionOK);
}
+// Tests that we don't crash with a range request if the disk cache was not
+// initialized properly.
+TEST(HttpCache, RangeGET_NoDiskCache) {
+ MockHttpCache cache(NULL);
+ cache.http_cache()->set_enable_range_support(true);
+ AddMockTransaction(&kRangeGET_TransactionOK);
+
+ RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK);
+ EXPECT_EQ(1, cache.network_layer()->transaction_count());
+
+ RemoveMockTransaction(&kRangeGET_TransactionOK);
+}
+
#ifdef NDEBUG
// This test hits a NOTREACHED so it is a release mode only test.
TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) {