Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Unified Diff: net/http/http_cache_unittest.cc

Issue 545101: Http cache: If we issue a byte range request for x bytes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
===================================================================
--- net/http/http_cache_unittest.cc (revision 36420)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -3331,6 +3331,47 @@
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) {
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698