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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), | 255 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), |
256 response, log, load_timing_info, nullptr, nullptr, | 256 response, log, load_timing_info, nullptr, nullptr, |
257 nullptr); | 257 nullptr); |
258 } | 258 } |
259 | 259 |
260 void RunTransactionTestWithResponse(HttpCache* cache, | 260 void RunTransactionTestWithResponse(HttpCache* cache, |
261 const MockTransaction& trans_info, | 261 const MockTransaction& trans_info, |
262 std::string* response_headers) { | 262 std::string* response_headers) { |
263 HttpResponseInfo response; | 263 HttpResponseInfo response; |
264 RunTransactionTestWithResponseInfo(cache, trans_info, &response); | 264 RunTransactionTestWithResponseInfo(cache, trans_info, &response); |
265 response.headers->GetNormalizedHeaders(response_headers); | 265 *response_headers = HttpUtil::ConvertHeadersBackToHTTPResponse( |
| 266 response.headers->raw_headers()); |
266 } | 267 } |
267 | 268 |
268 void RunTransactionTestWithResponseAndGetTiming( | 269 void RunTransactionTestWithResponseAndGetTiming( |
269 HttpCache* cache, | 270 HttpCache* cache, |
270 const MockTransaction& trans_info, | 271 const MockTransaction& trans_info, |
271 std::string* response_headers, | 272 std::string* response_headers, |
272 const NetLogWithSource& log, | 273 const NetLogWithSource& log, |
273 LoadTimingInfo* load_timing_info) { | 274 LoadTimingInfo* load_timing_info) { |
274 HttpResponseInfo response; | 275 HttpResponseInfo response; |
275 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), | 276 RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info), |
276 &response, log, load_timing_info, nullptr, nullptr, | 277 &response, log, load_timing_info, nullptr, nullptr, |
277 nullptr); | 278 nullptr); |
278 response.headers->GetNormalizedHeaders(response_headers); | 279 *response_headers = HttpUtil::ConvertHeadersBackToHTTPResponse( |
| 280 response.headers->raw_headers()); |
279 } | 281 } |
280 | 282 |
281 // This class provides a handler for kFastNoStoreGET_Transaction so that the | 283 // This class provides a handler for kFastNoStoreGET_Transaction so that the |
282 // no-store header can be included on demand. | 284 // no-store header can be included on demand. |
283 class FastTransactionServer { | 285 class FastTransactionServer { |
284 public: | 286 public: |
285 FastTransactionServer() { | 287 FastTransactionServer() { |
286 no_store = false; | 288 no_store = false; |
287 } | 289 } |
288 ~FastTransactionServer() {} | 290 ~FastTransactionServer() {} |
(...skipping 6410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6699 | 6701 |
6700 HttpResponseInfo response; | 6702 HttpResponseInfo response; |
6701 RunTransactionTestWithResponseInfo(cache.http_cache(), request, &response); | 6703 RunTransactionTestWithResponseInfo(cache.http_cache(), request, &response); |
6702 | 6704 |
6703 // The request and response times should have been updated. | 6705 // The request and response times should have been updated. |
6704 EXPECT_EQ(request_time.ToInternalValue(), | 6706 EXPECT_EQ(request_time.ToInternalValue(), |
6705 response.request_time.ToInternalValue()); | 6707 response.request_time.ToInternalValue()); |
6706 EXPECT_EQ(response_time.ToInternalValue(), | 6708 EXPECT_EQ(response_time.ToInternalValue(), |
6707 response.response_time.ToInternalValue()); | 6709 response.response_time.ToInternalValue()); |
6708 | 6710 |
6709 std::string headers; | 6711 std::string headers = HttpUtil::ConvertHeadersBackToHTTPResponse( |
6710 response.headers->GetNormalizedHeaders(&headers); | 6712 response.headers->raw_headers()); |
6711 | 6713 |
6712 EXPECT_EQ("HTTP/1.1 200 OK\n" | 6714 EXPECT_EQ("HTTP/1.1 200 OK\n" |
6713 "Date: Wed, 22 Jul 2009 03:15:26 GMT\n" | 6715 "Date: Wed, 22 Jul 2009 03:15:26 GMT\n" |
6714 "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n", | 6716 "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n", |
6715 headers); | 6717 headers); |
6716 | 6718 |
6717 RemoveMockTransaction(&mock_network_response); | 6719 RemoveMockTransaction(&mock_network_response); |
6718 } | 6720 } |
6719 | 6721 |
6720 // Tests that we can write metadata to an entry. | 6722 // Tests that we can write metadata to an entry. |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8254 RunTransactionTestWithResponseInfo(cache.http_cache(), | 8256 RunTransactionTestWithResponseInfo(cache.http_cache(), |
8255 kTypicalGET_Transaction, &response_info); | 8257 kTypicalGET_Transaction, &response_info); |
8256 | 8258 |
8257 EXPECT_FALSE(response_info.was_cached); | 8259 EXPECT_FALSE(response_info.was_cached); |
8258 EXPECT_TRUE(response_info.network_accessed); | 8260 EXPECT_TRUE(response_info.network_accessed); |
8259 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, | 8261 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, |
8260 response_info.cache_entry_status); | 8262 response_info.cache_entry_status); |
8261 } | 8263 } |
8262 | 8264 |
8263 } // namespace net | 8265 } // namespace net |
OLD | NEW |