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

Unified Diff: net/http/http_cache_unittest.cc

Issue 10829069: Http cache: Make sure that issuing a byte range request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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') | net/http/partial_data.cc » ('j') | 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 148620)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -2760,6 +2760,31 @@
RemoveMockTransaction(&kRangeGET_TransactionOK);
}
+// Tests that we cache 301s for range requests.
+TEST(HttpCache, RangeGET_301) {
+ MockHttpCache cache;
+ ScopedMockTransaction transaction(kRangeGET_TransactionOK);
+ transaction.status = "HTTP/1.1 301 Moved Permanently";
+ transaction.response_headers = "Location: http://www.bar.com/\n";
+ transaction.data = "";
+ transaction.handler = NULL;
+ 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());
+
+ // Read from the cache.
+ RunTransactionTest(cache.http_cache(), transaction);
+ EXPECT_EQ(1, cache.network_layer()->transaction_count());
+ EXPECT_EQ(1, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+
+ RemoveMockTransaction(&transaction);
+}
+
// Tests that we can cache range requests when the start or end is unknown.
// We start with one suffix request, followed by a request from a given point.
TEST(HttpCache, UnknownRangeGET_1) {
@@ -3139,13 +3164,13 @@
// Make a request for an invalid range.
MockTransaction transaction3(kRangeGET_TransactionOK);
transaction3.request_headers = "Range: bytes = 80-90\r\n" EXTRA_HEADER;
- transaction3.data = "";
+ transaction3.data = transaction.data;
transaction3.load_flags = net::LOAD_PREFERRING_CACHE;
RunTransactionTestWithResponse(cache.http_cache(), transaction3, &headers);
EXPECT_EQ(2, cache.disk_cache()->open_count());
- EXPECT_EQ(0U, headers.find("HTTP/1.1 416 "));
- EXPECT_NE(std::string::npos, headers.find("Content-Range: bytes 0-0/80"));
- EXPECT_NE(std::string::npos, headers.find("Content-Length: 0"));
+ EXPECT_EQ(0U, headers.find("HTTP/1.1 200 "));
+ EXPECT_EQ(std::string::npos, headers.find("Content-Range:"));
+ EXPECT_EQ(std::string::npos, headers.find("Content-Length: 80"));
// Make sure the entry is deactivated.
MessageLoop::current()->RunAllPending();
@@ -3162,7 +3187,7 @@
transaction2.request_headers = kRangeGET_TransactionOK.request_headers;
RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers);
Verify206Response(headers, 40, 49);
- EXPECT_EQ(5, cache.network_layer()->transaction_count());
+ EXPECT_EQ(4, cache.network_layer()->transaction_count());
EXPECT_EQ(4, cache.disk_cache()->open_count());
EXPECT_EQ(1, cache.disk_cache()->create_count());
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/partial_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698