| 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 void Verify206Response(const std::string& response, int start, int end) { | 494 void Verify206Response(const std::string& response, int start, int end) { |
| 495 std::string raw_headers( | 495 std::string raw_headers( |
| 496 HttpUtil::AssembleRawHeaders(response.data(), response.size())); | 496 HttpUtil::AssembleRawHeaders(response.data(), response.size())); |
| 497 scoped_refptr<HttpResponseHeaders> headers( | 497 scoped_refptr<HttpResponseHeaders> headers( |
| 498 new HttpResponseHeaders(raw_headers)); | 498 new HttpResponseHeaders(raw_headers)); |
| 499 | 499 |
| 500 ASSERT_EQ(206, headers->response_code()); | 500 ASSERT_EQ(206, headers->response_code()); |
| 501 | 501 |
| 502 int64_t range_start, range_end, object_size; | 502 int64_t range_start, range_end, object_size; |
| 503 ASSERT_TRUE( | 503 ASSERT_TRUE( |
| 504 headers->GetContentRange(&range_start, &range_end, &object_size)); | 504 headers->GetContentRangeFor206(&range_start, &range_end, &object_size)); |
| 505 int64_t content_length = headers->GetContentLength(); | 505 int64_t content_length = headers->GetContentLength(); |
| 506 | 506 |
| 507 int length = end - start + 1; | 507 int length = end - start + 1; |
| 508 ASSERT_EQ(length, content_length); | 508 ASSERT_EQ(length, content_length); |
| 509 ASSERT_EQ(start, range_start); | 509 ASSERT_EQ(start, range_start); |
| 510 ASSERT_EQ(end, range_end); | 510 ASSERT_EQ(end, range_end); |
| 511 } | 511 } |
| 512 | 512 |
| 513 // Creates a truncated entry that can be resumed using byte ranges. | 513 // Creates a truncated entry that can be resumed using byte ranges. |
| 514 void CreateTruncatedEntry(std::string raw_headers, MockHttpCache* cache) { | 514 void CreateTruncatedEntry(std::string raw_headers, MockHttpCache* cache) { |
| (...skipping 7739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8254 RunTransactionTestWithResponseInfo(cache.http_cache(), | 8254 RunTransactionTestWithResponseInfo(cache.http_cache(), |
| 8255 kTypicalGET_Transaction, &response_info); | 8255 kTypicalGET_Transaction, &response_info); |
| 8256 | 8256 |
| 8257 EXPECT_FALSE(response_info.was_cached); | 8257 EXPECT_FALSE(response_info.was_cached); |
| 8258 EXPECT_TRUE(response_info.network_accessed); | 8258 EXPECT_TRUE(response_info.network_accessed); |
| 8259 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, | 8259 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, |
| 8260 response_info.cache_entry_status); | 8260 response_info.cache_entry_status); |
| 8261 } | 8261 } |
| 8262 | 8262 |
| 8263 } // namespace net | 8263 } // namespace net |
| OLD | NEW |