OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 EXPECT_EQ(2, cache.network_layer()->transaction_count()); | 813 EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
814 EXPECT_EQ(1, cache.disk_cache()->open_count()); | 814 EXPECT_EQ(1, cache.disk_cache()->open_count()); |
815 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 815 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
816 } | 816 } |
817 | 817 |
818 static void ETagGet_ConditionalRequest_Handler( | 818 static void ETagGet_ConditionalRequest_Handler( |
819 const net::HttpRequestInfo* request, | 819 const net::HttpRequestInfo* request, |
820 std::string* response_status, | 820 std::string* response_status, |
821 std::string* response_headers, | 821 std::string* response_headers, |
822 std::string* response_data) { | 822 std::string* response_data) { |
823 EXPECT_TRUE(request->extra_headers.find("If-None-Match") != std::string::npos)
; | 823 EXPECT_TRUE(request->extra_headers.find("If-None-Match") != |
| 824 std::string::npos); |
824 response_status->assign("HTTP/1.1 304 Not Modified"); | 825 response_status->assign("HTTP/1.1 304 Not Modified"); |
825 response_headers->assign(kETagGET_Transaction.response_headers); | 826 response_headers->assign(kETagGET_Transaction.response_headers); |
826 response_data->clear(); | 827 response_data->clear(); |
827 } | 828 } |
828 | 829 |
829 TEST(HttpCache, ETagGET_ConditionalRequest_304) { | 830 TEST(HttpCache, ETagGET_ConditionalRequest_304) { |
830 MockHttpCache cache; | 831 MockHttpCache cache; |
831 | 832 |
832 ScopedMockTransaction transaction(kETagGET_Transaction); | 833 ScopedMockTransaction transaction(kETagGET_Transaction); |
833 | 834 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 EXPECT_EQ(0, cache.disk_cache()->create_count()); | 951 EXPECT_EQ(0, cache.disk_cache()->create_count()); |
951 | 952 |
952 MockTransaction transaction(kSimpleGET_Transaction); | 953 MockTransaction transaction(kSimpleGET_Transaction); |
953 transaction.request_headers = "If-None-Match: foo"; | 954 transaction.request_headers = "If-None-Match: foo"; |
954 RunTransactionTest(cache.http_cache(), transaction); | 955 RunTransactionTest(cache.http_cache(), transaction); |
955 | 956 |
956 EXPECT_EQ(2, cache.network_layer()->transaction_count()); | 957 EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
957 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 958 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
958 EXPECT_EQ(0, cache.disk_cache()->create_count()); | 959 EXPECT_EQ(0, cache.disk_cache()->create_count()); |
959 | 960 |
960 transaction.request_headers = "If-Modified-Since: Wed, 28 Nov 2007 00:45:20 GM
T"; | 961 transaction.request_headers = |
| 962 "If-Modified-Since: Wed, 28 Nov 2007 00:45:20 GMT"; |
961 RunTransactionTest(cache.http_cache(), transaction); | 963 RunTransactionTest(cache.http_cache(), transaction); |
962 | 964 |
963 EXPECT_EQ(3, cache.network_layer()->transaction_count()); | 965 EXPECT_EQ(3, cache.network_layer()->transaction_count()); |
964 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 966 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
965 EXPECT_EQ(0, cache.disk_cache()->create_count()); | 967 EXPECT_EQ(0, cache.disk_cache()->create_count()); |
966 } | 968 } |
967 | 969 |
968 TEST(HttpCache, SyncRead) { | 970 TEST(HttpCache, SyncRead) { |
969 MockHttpCache cache; | 971 MockHttpCache cache; |
970 | 972 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 | 1274 |
1273 const net::HttpResponseInfo* response = trans->GetResponseInfo(); | 1275 const net::HttpResponseInfo* response = trans->GetResponseInfo(); |
1274 ASSERT_TRUE(response); | 1276 ASSERT_TRUE(response); |
1275 | 1277 |
1276 // Make sure we get the same file handle as in the first request. | 1278 // Make sure we get the same file handle as in the first request. |
1277 ASSERT_EQ(kFakePlatformFile1, response->response_data_file); | 1279 ASSERT_EQ(kFakePlatformFile1, response->response_data_file); |
1278 | 1280 |
1279 ReadAndVerifyTransaction(trans.get(), trans_info); | 1281 ReadAndVerifyTransaction(trans.get(), trans_info); |
1280 } | 1282 } |
1281 } | 1283 } |
OLD | NEW |