| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 3151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3162 transaction.url = kRangeGET_TransactionOK.url; | 3162 transaction.url = kRangeGET_TransactionOK.url; |
| 3163 transaction.method = "HEAD"; | 3163 transaction.method = "HEAD"; |
| 3164 transaction.data = ""; | 3164 transaction.data = ""; |
| 3165 AddMockTransaction(&transaction); | 3165 AddMockTransaction(&transaction); |
| 3166 std::string headers; | 3166 std::string headers; |
| 3167 | 3167 |
| 3168 // Load from cache. | 3168 // Load from cache. |
| 3169 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); | 3169 RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
| 3170 | 3170 |
| 3171 EXPECT_NE(std::string::npos, headers.find("HTTP/1.1 200 OK\n")); | 3171 EXPECT_NE(std::string::npos, headers.find("HTTP/1.1 200 OK\n")); |
| 3172 EXPECT_EQ(std::string::npos, headers.find("Content-Length")); | 3172 EXPECT_NE(std::string::npos, headers.find("Content-Length: 80\n")); |
| 3173 EXPECT_EQ(std::string::npos, headers.find("Content-Range")); | 3173 EXPECT_EQ(std::string::npos, headers.find("Content-Range")); |
| 3174 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 3174 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
| 3175 EXPECT_EQ(1, cache.disk_cache()->open_count()); | 3175 EXPECT_EQ(1, cache.disk_cache()->open_count()); |
| 3176 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 3176 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| 3177 RemoveMockTransaction(&transaction); | 3177 RemoveMockTransaction(&transaction); |
| 3178 } | 3178 } |
| 3179 | 3179 |
| 3180 // Tests that a HEAD request can be served from a truncated resource. | 3180 // Tests that a HEAD request can be served from a truncated resource. |
| 3181 TEST(HttpCache, SimpleHEAD_WithTruncatedEntry) { | 3181 TEST(HttpCache, SimpleHEAD_WithTruncatedEntry) { |
| 3182 MockHttpCache cache; | 3182 MockHttpCache cache; |
| (...skipping 4586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7769 | 7769 |
| 7770 // Here the second transaction proceeds without reading the first body. | 7770 // Here the second transaction proceeds without reading the first body. |
| 7771 EXPECT_EQ(net::LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); | 7771 EXPECT_EQ(net::LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); |
| 7772 base::MessageLoop::current()->RunUntilIdle(); | 7772 base::MessageLoop::current()->RunUntilIdle(); |
| 7773 EXPECT_EQ(net::LOAD_STATE_IDLE, second->trans->GetLoadState()); | 7773 EXPECT_EQ(net::LOAD_STATE_IDLE, second->trans->GetLoadState()); |
| 7774 ASSERT_TRUE(second->trans->GetResponseInfo()); | 7774 ASSERT_TRUE(second->trans->GetResponseInfo()); |
| 7775 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( | 7775 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( |
| 7776 "Cache-Control", "no-store")); | 7776 "Cache-Control", "no-store")); |
| 7777 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); | 7777 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); |
| 7778 } | 7778 } |
| OLD | NEW |