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

Unified Diff: net/http/http_cache_unittest.cc

Issue 177016: Http cache: Bypass the cache for range requests that have validation headers.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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.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 24666)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -1639,7 +1639,6 @@
TEST(HttpCache, RangeGET_SkipsCache) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
// Test that we skip the cache for range GET requests. Eventually, we will
// want to cache these, but we'll still have cases where skipping the cache
@@ -1668,6 +1667,39 @@
EXPECT_EQ(0, cache.disk_cache()->create_count());
}
+// Test that we skip the cache for range requests that include a validation
+// header.
+TEST(HttpCache, RangeGET_SkipsCache2) {
+ MockHttpCache cache;
+ cache.http_cache()->set_enable_range_support(true);
+
+ MockTransaction transaction(kRangeGET_Transaction);
+ transaction.request_headers = "If-None-Match: foo\n"
+ "Range: bytes = 40-49\n";
+ RunTransactionTest(cache.http_cache(), transaction);
+
+ EXPECT_EQ(1, cache.network_layer()->transaction_count());
+ EXPECT_EQ(0, cache.disk_cache()->open_count());
+ EXPECT_EQ(0, cache.disk_cache()->create_count());
+
+ transaction.request_headers =
+ "If-Modified-Since: Wed, 28 Nov 2007 00:45:20 GMT\n"
+ "Range: bytes = 40-49\n";
+ RunTransactionTest(cache.http_cache(), transaction);
+
+ EXPECT_EQ(2, cache.network_layer()->transaction_count());
+ EXPECT_EQ(0, cache.disk_cache()->open_count());
+ EXPECT_EQ(0, cache.disk_cache()->create_count());
+
+ transaction.request_headers = "If-Range: bla\n"
+ "Range: bytes = 40-49\n";
+ RunTransactionTest(cache.http_cache(), transaction);
+
+ EXPECT_EQ(3, cache.network_layer()->transaction_count());
+ EXPECT_EQ(0, cache.disk_cache()->open_count());
+ EXPECT_EQ(0, cache.disk_cache()->create_count());
+}
+
// Tests that receiving 206 for a regular request is handled correctly.
TEST(HttpCache, GET_Crazy206) {
MockHttpCache cache;
« no previous file with comments | « net/http/http_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698