OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 897 |
898 EXPECT_LT(end, 80); | 898 EXPECT_LT(end, 80); |
899 | 899 |
900 std::string content_range = base::StringPrintf( | 900 std::string content_range = base::StringPrintf( |
901 "Content-Range: bytes %d-%d/80\n", start, end); | 901 "Content-Range: bytes %d-%d/80\n", start, end); |
902 response_headers->append(content_range); | 902 response_headers->append(content_range); |
903 | 903 |
904 if (!request->extra_headers.HasHeader("If-None-Match") || modified_) { | 904 if (!request->extra_headers.HasHeader("If-None-Match") || modified_) { |
905 EXPECT_EQ(9, (end - start) % 10); | 905 EXPECT_EQ(9, (end - start) % 10); |
906 std::string data; | 906 std::string data; |
907 for (int block_start = start; block_start < end; block_start += 10) | 907 for (int block_start = start; block_start < end; block_start += 10) { |
908 StringAppendF(&data, "rg: %02d-%02d ", block_start, block_start + 9); | 908 base::StringAppendF(&data, "rg: %02d-%02d ", |
| 909 block_start, block_start + 9); |
| 910 } |
909 *response_data = data; | 911 *response_data = data; |
910 | 912 |
911 if (end - start != 9) { | 913 if (end - start != 9) { |
912 // We also have to fix content-length. | 914 // We also have to fix content-length. |
913 int len = end - start + 1; | 915 int len = end - start + 1; |
914 EXPECT_EQ(0, len % 10); | 916 EXPECT_EQ(0, len % 10); |
915 std::string content_length = base::StringPrintf("Content-Length: %d\n", | 917 std::string content_length = base::StringPrintf("Content-Length: %d\n", |
916 len); | 918 len); |
917 response_headers->replace(response_headers->find("Content-Length:"), | 919 response_headers->replace(response_headers->find("Content-Length:"), |
918 content_length.size(), content_length); | 920 content_length.size(), content_length); |
(...skipping 3924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4843 // Now return 200 when validating the entry so the metadata will be lost. | 4845 // Now return 200 when validating the entry so the metadata will be lost. |
4844 MockTransaction trans2(kTypicalGET_Transaction); | 4846 MockTransaction trans2(kTypicalGET_Transaction); |
4845 trans2.load_flags = net::LOAD_VALIDATE_CACHE; | 4847 trans2.load_flags = net::LOAD_VALIDATE_CACHE; |
4846 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); | 4848 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); |
4847 EXPECT_TRUE(response.metadata.get() == NULL); | 4849 EXPECT_TRUE(response.metadata.get() == NULL); |
4848 | 4850 |
4849 EXPECT_EQ(3, cache.network_layer()->transaction_count()); | 4851 EXPECT_EQ(3, cache.network_layer()->transaction_count()); |
4850 EXPECT_EQ(4, cache.disk_cache()->open_count()); | 4852 EXPECT_EQ(4, cache.disk_cache()->open_count()); |
4851 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 4853 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
4852 } | 4854 } |
OLD | NEW |