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

Side by Side Diff: net/http/http_cache_unittest.cc

Issue 348053: Http cache: Make sure that we handle byte range requests that... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« net/http/http_cache.cc ('K') | « net/http/http_cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include "base/hash_tables.h" 7 #include "base/hash_tables.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_vector.h" 9 #include "base/scoped_vector.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 MockHttpCache cache(NULL); 2807 MockHttpCache cache(NULL);
2808 cache.http_cache()->set_enable_range_support(true); 2808 cache.http_cache()->set_enable_range_support(true);
2809 AddMockTransaction(&kRangeGET_TransactionOK); 2809 AddMockTransaction(&kRangeGET_TransactionOK);
2810 2810
2811 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); 2811 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK);
2812 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 2812 EXPECT_EQ(1, cache.network_layer()->transaction_count());
2813 2813
2814 RemoveMockTransaction(&kRangeGET_TransactionOK); 2814 RemoveMockTransaction(&kRangeGET_TransactionOK);
2815 } 2815 }
2816 2816
2817 // Tests that we handle byte range requests that skip the cache.
2818 TEST(HttpCache, RangeHEAD) {
2819 MockHttpCache cache;
2820 cache.http_cache()->set_enable_range_support(true);
2821 AddMockTransaction(&kRangeGET_TransactionOK);
2822
2823 MockTransaction transaction(kRangeGET_TransactionOK);
2824 transaction.request_headers = "Range: bytes = -10\r\n" EXTRA_HEADER;
2825 transaction.method = "HEAD";
2826 transaction.data = "rg: 70-79 ";
2827
2828 std::string headers;
2829 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
2830
2831 EXPECT_TRUE(Verify206Response(headers, 70, 79));
2832 EXPECT_EQ(1, cache.network_layer()->transaction_count());
2833 EXPECT_EQ(0, cache.disk_cache()->open_count());
2834 EXPECT_EQ(0, cache.disk_cache()->create_count());
2835
2836 RemoveMockTransaction(&kRangeGET_TransactionOK);
2837 }
2838
2817 #ifdef NDEBUG 2839 #ifdef NDEBUG
2818 // This test hits a NOTREACHED so it is a release mode only test. 2840 // This test hits a NOTREACHED so it is a release mode only test.
2819 TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) { 2841 TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) {
2820 MockHttpCache cache; 2842 MockHttpCache cache;
2821 cache.http_cache()->set_enable_range_support(true); 2843 cache.http_cache()->set_enable_range_support(true);
2822 AddMockTransaction(&kRangeGET_TransactionOK); 2844 AddMockTransaction(&kRangeGET_TransactionOK);
2823 2845
2824 // Write to the cache (40-49). 2846 // Write to the cache (40-49).
2825 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); 2847 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK);
2826 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 2848 EXPECT_EQ(1, cache.network_layer()->transaction_count());
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
3388 std::string headers; 3410 std::string headers;
3389 response.headers->GetNormalizedHeaders(&headers); 3411 response.headers->GetNormalizedHeaders(&headers);
3390 3412
3391 EXPECT_EQ("HTTP/1.1 200 OK\n" 3413 EXPECT_EQ("HTTP/1.1 200 OK\n"
3392 "Date: Wed, 22 Jul 2009 03:15:26 GMT\n" 3414 "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
3393 "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n", 3415 "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
3394 headers); 3416 headers);
3395 3417
3396 RemoveMockTransaction(&mock_network_response); 3418 RemoveMockTransaction(&mock_network_response);
3397 } 3419 }
OLDNEW
« net/http/http_cache.cc ('K') | « net/http/http_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698