summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache_unittest.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 18:49:47 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 18:49:47 +0000
commit7ee4c40760270f17c2cdaa02e327dd3ec1453c9b (patch)
treec98566076a628a037d549c9da19b3ffbe76d4b9e /net/http/http_cache_unittest.cc
parentab83889ea0a2351c800e9b4697c04749bdc2e255 (diff)
downloadchromium_src-7ee4c40760270f17c2cdaa02e327dd3ec1453c9b.zip
chromium_src-7ee4c40760270f17c2cdaa02e327dd3ec1453c9b.tar.gz
chromium_src-7ee4c40760270f17c2cdaa02e327dd3ec1453c9b.tar.bz2
Fix a browser crash during cache validation.
It is possible for a crazy server to return 206 even though we are not making a range request. In that case, we should not allow the stored response to go through the logic for range support (which right now is disabled). We've always stored those 206s though. BUG=15617 TEST=unittest Review URL: http://codereview.chromium.org/150090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_unittest.cc')
-rw-r--r--net/http/http_cache_unittest.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index e72a871..1c74ca8 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -1189,6 +1189,30 @@ TEST(HttpCache, RangeGET_SkipsCache) {
EXPECT_EQ(0, cache.disk_cache()->create_count());
}
+TEST(HttpCache, GET_Crazy206) {
+ MockHttpCache cache;
+ AddMockTransaction(&kRangeGET_TransactionOK);
+
+ // Test that receiving 206 for a regular request is handled correctly.
+
+ // Write to the cache.
+ MockTransaction transaction(kRangeGET_TransactionOK);
+ transaction.request_headers = "";
+ RunTransactionTest(cache.http_cache(), transaction);
+
+ EXPECT_EQ(1, cache.network_layer()->transaction_count());
+ EXPECT_EQ(0, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+
+ // This should read again from the net.
+ RunTransactionTest(cache.http_cache(), transaction);
+
+ EXPECT_EQ(2, cache.network_layer()->transaction_count());
+ EXPECT_EQ(1, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+ RemoveMockTransaction(&kRangeGET_TransactionOK);
+}
+
TEST(HttpCache, DISABLED_RangeGET_OK) {
MockHttpCache cache;
AddMockTransaction(&kRangeGET_TransactionOK);