| Index: net/http/http_cache_unittest.cc
|
| diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
|
| index 4987c37b025a6aa89f8279586e4b811ba6ad9c30..329f9e401299f9d2ad0f1ebb25d63986406b05ea 100644
|
| --- a/net/http/http_cache_unittest.cc
|
| +++ b/net/http/http_cache_unittest.cc
|
| @@ -3652,15 +3652,17 @@ TEST(HttpCache, GET_Crazy416) {
|
| RemoveMockTransaction(&transaction);
|
| }
|
|
|
| -// Tests that we don't cache partial responses that can't be validated.
|
| +// Tests that we store partial responses that can't be validated, as they can
|
| +// be used for requests that don't require revalidation.
|
| TEST(HttpCache, RangeGET_NoStrongValidators) {
|
| MockHttpCache cache;
|
| std::string headers;
|
|
|
| - // Attempt to write to the cache (40-49).
|
| + // Write to the cache (40-49).
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| AddMockTransaction(&transaction);
|
| transaction.response_headers = "Content-Length: 10\n"
|
| + "Cache-Control: max-age=3600\n"
|
| "ETag: w/\"foo\"\n";
|
| RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
|
|
|
| @@ -3669,13 +3671,43 @@ TEST(HttpCache, RangeGET_NoStrongValidators) {
|
| EXPECT_EQ(0, cache.disk_cache()->open_count());
|
| EXPECT_EQ(1, cache.disk_cache()->create_count());
|
|
|
| - // Now verify that there's no cached data.
|
| + // Now verify that there's cached data.
|
| RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| - EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| + 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 failures to validate cache partial responses that lack strong
|
| +// validators.
|
| +TEST(HttpCache, RangeGET_NoValidation) {
|
| + MockHttpCache cache;
|
| + std::string headers;
|
| +
|
| + // Write to the cache (40-49).
|
| + MockTransaction transaction(kRangeGET_TransactionOK);
|
| + AddMockTransaction(&transaction);
|
| + transaction.response_headers = "Content-Length: 10\n"
|
| + "ETag: w/\"foo\"\n";
|
| + RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
|
| +
|
| + Verify206Response(headers, 40, 49);
|
| + 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 the cached data is not used.
|
| + RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| + &headers);
|
| +
|
| + Verify206Response(headers, 40, 49);
|
| + EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| + EXPECT_EQ(1, cache.disk_cache()->open_count());
|
| EXPECT_EQ(2, cache.disk_cache()->create_count());
|
|
|
| RemoveMockTransaction(&transaction);
|
|
|