diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-21 19:22:57 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-21 19:22:57 +0000 |
commit | c14117b97d9fee1ec586c92898262900c2079eec (patch) | |
tree | 57009a89fa95464e57868c3c66187abef09e1e23 /net/http/http_cache_unittest.cc | |
parent | 4e416ed9896dcd44547332f366c2767eb1223aa2 (diff) | |
download | chromium_src-c14117b97d9fee1ec586c92898262900c2079eec.zip chromium_src-c14117b97d9fee1ec586c92898262900c2079eec.tar.gz chromium_src-c14117b97d9fee1ec586c92898262900c2079eec.tar.bz2 |
Http cache: If we issue a byte range request for x bytes
and the server replies that it is giving us x bytes but
we receive less than that, forward the failure to the
caller instead of asking for another range.
BUG=31000
TEST=unittests
Review URL: http://codereview.chromium.org/545101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_unittest.cc')
-rw-r--r-- | net/http/http_cache_unittest.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 72231fb..764d1fd 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -3331,6 +3331,47 @@ TEST(HttpCache, RangeGET_FastFlakyServer) { RemoveMockTransaction(&transaction); } +// Tests that when the server gives us less data than expected, we don't keep +// asking for more data. +TEST(HttpCache, RangeGET_FastFlakyServer2) { + MockHttpCache cache; + cache.http_cache()->set_enable_range_support(true); + + // First, check with an empty cache (WRITE mode). + MockTransaction transaction(kRangeGET_TransactionOK); + transaction.request_headers = "Range: bytes = 40-49\r\n" EXTRA_HEADER; + transaction.data = "rg: 40-"; // Less than expected. + transaction.handler = NULL; + std::string headers(transaction.response_headers); + headers.append("Content-Range: bytes 40-49/80\n"); + transaction.response_headers = headers.c_str(); + + AddMockTransaction(&transaction); + + // Write to the cache. + 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()); + + // Now verify that even in READ_WRITE mode, we forward the bad response to + // the caller. + transaction.request_headers = "Range: bytes = 60-69\r\n" EXTRA_HEADER; + transaction.data = "rg: 60-"; // Less than expected. + headers = kRangeGET_TransactionOK.response_headers; + headers.append("Content-Range: bytes 60-69/80\n"); + transaction.response_headers = headers.c_str(); + + 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(&transaction); +} + #ifdef NDEBUG // This test hits a NOTREACHED so it is a release mode only test. TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) { |