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" |
11 #include "base/format_macros.h" | |
11 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/test/simple_test_clock.h" | 17 #include "base/test/simple_test_clock.h" |
17 #include "net/base/cache_type.h" | 18 #include "net/base/cache_type.h" |
18 #include "net/base/elements_upload_data_stream.h" | 19 #include "net/base/elements_upload_data_stream.h" |
19 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 "", | 270 "", |
270 LOAD_VALIDATE_CACHE, | 271 LOAD_VALIDATE_CACHE, |
271 "HTTP/1.1 200 OK", | 272 "HTTP/1.1 200 OK", |
272 "Cache-Control: max-age=10000\n", | 273 "Cache-Control: max-age=10000\n", |
273 base::Time(), | 274 base::Time(), |
274 "<html><body>Google Blah Blah</body></html>", | 275 "<html><body>Google Blah Blah</body></html>", |
275 TEST_MODE_SYNC_NET_START, | 276 TEST_MODE_SYNC_NET_START, |
276 &FastTransactionServer::FastNoStoreHandler, | 277 &FastTransactionServer::FastNoStoreHandler, |
277 nullptr, | 278 nullptr, |
278 0, | 279 0, |
279 0, | |
280 OK}; | 280 OK}; |
281 | 281 |
282 // This class provides a handler for kRangeGET_TransactionOK so that the range | 282 // This class provides a handler for kRangeGET_TransactionOK so that the range |
283 // request can be served on demand. | 283 // request can be served on demand. |
284 class RangeTransactionServer { | 284 class RangeTransactionServer { |
285 public: | 285 public: |
286 RangeTransactionServer() { | 286 RangeTransactionServer() { |
287 not_modified_ = false; | 287 not_modified_ = false; |
288 modified_ = false; | 288 modified_ = false; |
289 bad_200_ = false; | 289 bad_200_ = false; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 // AddHeadersFromString() (_not_ AddHeaderFromString()). | 335 // AddHeadersFromString() (_not_ AddHeaderFromString()). |
336 #define EXTRA_HEADER EXTRA_HEADER_LINE "\r\n" | 336 #define EXTRA_HEADER EXTRA_HEADER_LINE "\r\n" |
337 | 337 |
338 static const char kExtraHeaderKey[] = "Extra"; | 338 static const char kExtraHeaderKey[] = "Extra"; |
339 | 339 |
340 // Static. | 340 // Static. |
341 void RangeTransactionServer::RangeHandler(const HttpRequestInfo* request, | 341 void RangeTransactionServer::RangeHandler(const HttpRequestInfo* request, |
342 std::string* response_status, | 342 std::string* response_status, |
343 std::string* response_headers, | 343 std::string* response_headers, |
344 std::string* response_data) { | 344 std::string* response_data) { |
345 SCOPED_TRACE(testing::Message() << "Request headers: \n" | |
346 << request->extra_headers.ToString()); | |
345 if (request->extra_headers.IsEmpty()) { | 347 if (request->extra_headers.IsEmpty()) { |
346 response_status->assign("HTTP/1.1 416 Requested Range Not Satisfiable"); | 348 response_status->assign("HTTP/1.1 416 Requested Range Not Satisfiable"); |
347 response_data->clear(); | 349 response_data->clear(); |
348 return; | 350 return; |
349 } | 351 } |
350 | 352 |
351 // We want to make sure we don't delete extra headers. | 353 // We want to make sure we don't delete extra headers. |
352 EXPECT_TRUE(request->extra_headers.HasHeader(kExtraHeaderKey)); | 354 EXPECT_TRUE(request->extra_headers.HasHeader(kExtraHeaderKey)); |
353 | 355 |
354 bool require_auth = | 356 bool require_auth = |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n" | 444 "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n" |
443 "ETag: \"foo\"\n" | 445 "ETag: \"foo\"\n" |
444 "Accept-Ranges: bytes\n" | 446 "Accept-Ranges: bytes\n" |
445 "Content-Length: 10\n", | 447 "Content-Length: 10\n", |
446 base::Time(), | 448 base::Time(), |
447 "rg: 40-49 ", | 449 "rg: 40-49 ", |
448 TEST_MODE_NORMAL, | 450 TEST_MODE_NORMAL, |
449 &RangeTransactionServer::RangeHandler, | 451 &RangeTransactionServer::RangeHandler, |
450 nullptr, | 452 nullptr, |
451 0, | 453 0, |
452 0, | |
453 OK}; | 454 OK}; |
454 | 455 |
455 const char kFullRangeData[] = | 456 const char kFullRangeData[] = |
456 "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 " | 457 "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 " |
457 "rg: 40-49 rg: 50-59 rg: 60-69 rg: 70-79 "; | 458 "rg: 40-49 rg: 50-59 rg: 60-69 rg: 70-79 "; |
458 | 459 |
459 // Verifies the response headers (|response|) match a partial content | 460 // Verifies the response headers (|response|) match a partial content |
460 // response for the range starting at |start| and ending at |end|. | 461 // response for the range starting at |start| and ending at |end|. |
461 void Verify206Response(std::string response, int start, int end) { | 462 void Verify206Response(std::string response, int start, int end) { |
462 std::string raw_headers( | 463 std::string raw_headers( |
(...skipping 6248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6711 base::MessageLoop::current()->RunUntilIdle(); | 6712 base::MessageLoop::current()->RunUntilIdle(); |
6712 | 6713 |
6713 // Read from the cache. This should not deadlock. | 6714 // Read from the cache. This should not deadlock. |
6714 RunTransactionTest(cache.http_cache(), transaction); | 6715 RunTransactionTest(cache.http_cache(), transaction); |
6715 | 6716 |
6716 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 6717 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
6717 EXPECT_EQ(1, cache.disk_cache()->open_count()); | 6718 EXPECT_EQ(1, cache.disk_cache()->open_count()); |
6718 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 6719 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
6719 } | 6720 } |
6720 | 6721 |
6721 // Tests that we stop caching when told. | 6722 // Tests that calling StopCaching() causes the cache entry to be deleted if the |
6722 TEST(HttpCache, StopCachingDeletesEntry) { | 6723 // request cannot be resumed. |
6724 TEST(HttpCache, StopCachingDeletesEntryIfRequestIsNotResumable) { | |
6723 MockHttpCache cache; | 6725 MockHttpCache cache; |
6724 TestCompletionCallback callback; | 6726 TestCompletionCallback callback; |
6725 MockHttpRequest request(kSimpleGET_Transaction); | 6727 MockHttpRequest request(kSimpleGET_Transaction); |
6726 | 6728 |
6727 { | 6729 { |
6728 scoped_ptr<HttpTransaction> trans; | 6730 scoped_ptr<HttpTransaction> trans; |
6729 ASSERT_EQ(OK, cache.CreateTransaction(&trans)); | 6731 ASSERT_EQ(OK, cache.CreateTransaction(&trans)); |
6730 | 6732 |
6731 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6733 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
6732 EXPECT_EQ(OK, callback.GetResult(rv)); | 6734 EXPECT_EQ(OK, callback.GetResult(rv)); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6781 rv = trans->Read(buf.get(), 256, callback.callback()); | 6783 rv = trans->Read(buf.get(), 256, callback.callback()); |
6782 EXPECT_EQ(0, callback.GetResult(rv)); | 6784 EXPECT_EQ(0, callback.GetResult(rv)); |
6783 | 6785 |
6784 // We should be able to call DoneReading. | 6786 // We should be able to call DoneReading. |
6785 trans->DoneReading(); | 6787 trans->DoneReading(); |
6786 } | 6788 } |
6787 | 6789 |
6788 // Make sure that the ActiveEntry is gone. | 6790 // Make sure that the ActiveEntry is gone. |
6789 base::MessageLoop::current()->RunUntilIdle(); | 6791 base::MessageLoop::current()->RunUntilIdle(); |
6790 | 6792 |
6791 // Verify that the entry is gone. | 6793 // Verify that the entry is gone. The request is not resumeable, so the cache |
6794 // entry should be deleted if only part of the response was cached. | |
6792 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); | 6795 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
6793 | 6796 |
6794 EXPECT_EQ(2, cache.network_layer()->transaction_count()); | 6797 EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
6795 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 6798 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
6796 EXPECT_EQ(2, cache.disk_cache()->create_count()); | 6799 EXPECT_EQ(2, cache.disk_cache()->create_count()); |
6797 } | 6800 } |
6798 | 6801 |
6799 // Tests that we stop caching when told, when using auth. | 6802 // Tests that we stop caching when told, when using auth. |
6800 TEST(HttpCache, StopCachingWithAuthDeletesEntry) { | 6803 TEST(HttpCache, StopCachingWithAuthDeletesEntry) { |
6801 MockHttpCache cache; | 6804 MockHttpCache cache; |
(...skipping 23 matching lines...) Expand all Loading... | |
6825 | 6828 |
6826 // Verify that the entry is gone. | 6829 // Verify that the entry is gone. |
6827 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); | 6830 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
6828 | 6831 |
6829 EXPECT_EQ(2, cache.network_layer()->transaction_count()); | 6832 EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
6830 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 6833 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
6831 EXPECT_EQ(2, cache.disk_cache()->create_count()); | 6834 EXPECT_EQ(2, cache.disk_cache()->create_count()); |
6832 } | 6835 } |
6833 | 6836 |
6834 // Tests that when we are told to stop caching we don't throw away valid data. | 6837 // Tests that when we are told to stop caching we don't throw away valid data. |
6835 TEST(HttpCache, StopCachingSavesEntry) { | 6838 // If the request is resumable (i.e. has strong validators), then the cache |
6839 // should hold on to the partial response. | |
6840 TEST(HttpCache, StopCachingSavesEntryIfRequestIsResumable) { | |
6836 MockHttpCache cache; | 6841 MockHttpCache cache; |
6837 TestCompletionCallback callback; | 6842 TestCompletionCallback callback; |
6838 MockHttpRequest request(kSimpleGET_Transaction); | 6843 MockHttpRequest request(kSimpleGET_Transaction); |
6839 | 6844 |
6840 { | 6845 { |
6841 scoped_ptr<HttpTransaction> trans; | 6846 scoped_ptr<HttpTransaction> trans; |
6842 ASSERT_EQ(OK, cache.CreateTransaction(&trans)); | 6847 ASSERT_EQ(OK, cache.CreateTransaction(&trans)); |
6843 | 6848 |
6844 // Force a response that can be resumed. | 6849 // Force a response that can be resumed. |
6845 MockTransaction mock_transaction(kSimpleGET_Transaction); | 6850 MockTransaction mock_transaction(kSimpleGET_Transaction); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6897 scoped_ptr<HttpTransaction> trans; | 6902 scoped_ptr<HttpTransaction> trans; |
6898 ASSERT_EQ(OK, cache.CreateTransaction(&trans)); | 6903 ASSERT_EQ(OK, cache.CreateTransaction(&trans)); |
6899 | 6904 |
6900 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6905 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
6901 EXPECT_EQ(OK, callback.GetResult(rv)); | 6906 EXPECT_EQ(OK, callback.GetResult(rv)); |
6902 | 6907 |
6903 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); | 6908 scoped_refptr<IOBuffer> buf(new IOBuffer(256)); |
6904 rv = trans->Read(buf.get(), 10, callback.callback()); | 6909 rv = trans->Read(buf.get(), 10, callback.callback()); |
6905 EXPECT_EQ(callback.GetResult(rv), 10); | 6910 EXPECT_EQ(callback.GetResult(rv), 10); |
6906 | 6911 |
6907 // This is actually going to do nothing. | 6912 // This prevents any further writes to the cache entry, but doesn't discard |
6913 // the existing entry. | |
6908 trans->StopCaching(); | 6914 trans->StopCaching(); |
6909 | 6915 |
6910 // We should be able to keep reading. | 6916 // We should be able to keep reading. |
6911 rv = trans->Read(buf.get(), 256, callback.callback()); | 6917 rv = trans->Read(buf.get(), 256, callback.callback()); |
6912 EXPECT_GT(callback.GetResult(rv), 0); | 6918 EXPECT_GT(callback.GetResult(rv), 0); |
6913 rv = trans->Read(buf.get(), 256, callback.callback()); | 6919 rv = trans->Read(buf.get(), 256, callback.callback()); |
6914 EXPECT_GT(callback.GetResult(rv), 0); | 6920 EXPECT_GT(callback.GetResult(rv), 0); |
6915 rv = trans->Read(buf.get(), 256, callback.callback()); | 6921 rv = trans->Read(buf.get(), 256, callback.callback()); |
6916 EXPECT_EQ(callback.GetResult(rv), 0); | 6922 EXPECT_EQ(callback.GetResult(rv), 0); |
6917 } | 6923 } |
6918 | 6924 |
6919 // Verify that the disk entry was updated. | 6925 // Verify that the disk entry was not updated. |
6920 disk_cache::Entry* entry; | 6926 disk_cache::Entry* entry; |
6921 ASSERT_TRUE(cache.OpenBackendEntry(kRangeGET_TransactionOK.url, &entry)); | 6927 ASSERT_TRUE(cache.OpenBackendEntry(kRangeGET_TransactionOK.url, &entry)); |
6922 EXPECT_EQ(80, entry->GetDataSize(1)); | 6928 EXPECT_EQ(20, entry->GetDataSize(1)); |
6923 bool truncated = true; | 6929 bool truncated = false; |
6924 HttpResponseInfo response; | 6930 HttpResponseInfo response; |
6925 EXPECT_TRUE(MockHttpCache::ReadResponseInfo(entry, &response, &truncated)); | 6931 EXPECT_TRUE(MockHttpCache::ReadResponseInfo(entry, &response, &truncated)); |
6926 EXPECT_FALSE(truncated); | 6932 EXPECT_TRUE(truncated); |
6927 entry->Close(); | 6933 entry->Close(); |
6928 | 6934 |
6929 RemoveMockTransaction(&kRangeGET_TransactionOK); | 6935 RemoveMockTransaction(&kRangeGET_TransactionOK); |
6930 } | 6936 } |
6931 | 6937 |
6938 namespace { | |
6939 | |
6940 const int64 kTotalSize = 5000000000LL; // Five beeeeeelllliooonn bytes! | |
6941 | |
6942 void ExpectByteRangeTransactionHandler(const net::HttpRequestInfo* request, | |
6943 std::string* response_status, | |
6944 std::string* response_headers, | |
6945 std::string* response_data) { | |
6946 std::string if_range; | |
6947 EXPECT_TRUE(request->extra_headers.GetHeader( | |
6948 net::HttpRequestHeaders::kIfRange, &if_range)); | |
6949 EXPECT_EQ("\"foo\"", if_range); | |
6950 | |
6951 std::string range_header; | |
6952 EXPECT_TRUE(request->extra_headers.GetHeader(net::HttpRequestHeaders::kRange, | |
6953 &range_header)); | |
6954 std::vector<net::HttpByteRange> ranges; | |
6955 | |
6956 EXPECT_TRUE(net::HttpUtil::ParseRangeHeader(range_header, &ranges)); | |
6957 ASSERT_EQ(1u, ranges.size()); | |
6958 | |
6959 net::HttpByteRange range = ranges[0]; | |
6960 EXPECT_TRUE(range.HasFirstBytePosition()); | |
6961 EXPECT_TRUE(range.HasLastBytePosition()); | |
6962 | |
6963 response_status->assign("HTTP/1.1 206 Partial"); | |
6964 response_headers->assign(base::StringPrintf( | |
6965 "Content-Range: bytes %" PRId64 "-%" PRId64 "/%" PRId64 | |
6966 "\n" | |
6967 "Content-Length: %" PRId64 "\n", | |
6968 range.first_byte_position(), range.last_byte_position(), kTotalSize, | |
6969 range.last_byte_position() - range.first_byte_position() + 1)); | |
6970 } | |
6971 | |
6972 int LargeBufferReader(int64 content_length, | |
6973 int64 offset, | |
6974 net::IOBuffer* buf, | |
6975 int buf_len) { | |
6976 EXPECT_LT(0, content_length); | |
6977 EXPECT_LE(offset, content_length); | |
6978 int num = std::min(static_cast<int64>(buf_len), content_length - offset); | |
6979 return num; | |
6980 } | |
6981 | |
6982 void SetFlagOnBeforeNetworkStart(bool* started, bool* /* defer */) { | |
6983 *started = true; | |
6984 } | |
6985 | |
6986 void StopCachingOnBeforeNetworkStart(HttpTransaction* transaction, | |
6987 bool* /* defer */) { | |
6988 transaction->StopCaching(); | |
6989 } | |
6990 | |
6991 enum TransactionPhases { | |
6992 TRANSACTION_PHASE_BEFORE_FIRST_READ, | |
6993 TRANSACTION_PHASE_ON_BEFORE_NETWORK_START, | |
6994 TRANSACTION_PHASE_AFTER_FIRST_READ, | |
6995 TRANSACTION_PHASE_AFTER_NETWORK_READ | |
6996 }; | |
6997 | |
6998 class HttpCacheTestWithPhases | |
6999 : public ::testing::TestWithParam<TransactionPhases> {}; | |
7000 | |
7001 INSTANTIATE_TEST_CASE_P( | |
7002 Phase, | |
7003 HttpCacheTestWithPhases, | |
7004 ::testing::Values(TRANSACTION_PHASE_BEFORE_FIRST_READ, | |
7005 TRANSACTION_PHASE_ON_BEFORE_NETWORK_START, | |
7006 TRANSACTION_PHASE_AFTER_FIRST_READ, | |
7007 TRANSACTION_PHASE_AFTER_NETWORK_READ)); | |
7008 | |
7009 } // namespace | |
7010 | |
7011 TEST_P(HttpCacheTestWithPhases, | |
7012 StopCachingFollowedByReadForHugeTruncatedResource) { | |
7013 MockHttpCache cache; | |
7014 MockTransaction transaction(kSimpleGET_Transaction); | |
7015 transaction.url = kRangeGET_TransactionOK.url; | |
7016 transaction.handler = &ExpectByteRangeTransactionHandler; | |
7017 transaction.read_handler = &LargeBufferReader; | |
7018 ScopedMockTransaction scoped_transaction(transaction); | |
7019 | |
7020 std::string cached_headers = base::StringPrintf( | |
7021 "HTTP/1.1 200 OK\n" | |
7022 "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n" | |
7023 "ETag: \"foo\"\n" | |
7024 "Accept-Ranges: bytes\n" | |
7025 "Content-Length: %" PRId64 "\n", | |
7026 kTotalSize); | |
7027 CreateTruncatedEntry(cached_headers, &cache); | |
7028 | |
7029 MockHttpRequest request(transaction); | |
7030 net::TestCompletionCallback callback; | |
7031 scoped_ptr<net::HttpTransaction> http_transaction; | |
7032 int rv = cache.http_cache()->CreateTransaction(net::DEFAULT_PRIORITY, | |
7033 &http_transaction); | |
7034 ASSERT_EQ(net::OK, rv); | |
7035 ASSERT_TRUE(http_transaction.get()); | |
7036 | |
7037 if (GetParam() == TRANSACTION_PHASE_ON_BEFORE_NETWORK_START) | |
7038 http_transaction->SetBeforeNetworkStartCallback( | |
7039 base::Bind(&StopCachingOnBeforeNetworkStart, http_transaction.get())); | |
7040 | |
7041 bool network_transaction_started = false; | |
7042 if (GetParam() == TRANSACTION_PHASE_AFTER_NETWORK_READ) | |
7043 http_transaction->SetBeforeNetworkStartCallback( | |
7044 base::Bind(&SetFlagOnBeforeNetworkStart, &network_transaction_started)); | |
7045 | |
7046 rv = http_transaction->Start(&request, callback.callback(), | |
7047 net::BoundNetLog()); | |
7048 rv = callback.GetResult(rv); | |
7049 ASSERT_EQ(net::OK, rv); | |
7050 | |
7051 if (GetParam() == TRANSACTION_PHASE_BEFORE_FIRST_READ) | |
7052 http_transaction->StopCaching(); | |
7053 | |
7054 int64 total_bytes_received = 0; | |
7055 | |
7056 EXPECT_EQ(kTotalSize, | |
7057 http_transaction->GetResponseInfo()->headers->GetContentLength()); | |
7058 do { | |
7059 // This test simulates reading Gigabytes of data. Buffer size is set to 1MB | |
7060 // to reduce the number of reads and speedup the test. | |
7061 const int kBufferSize = 1024 * 1024; | |
7062 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kBufferSize)); | |
7063 rv = http_transaction->Read(buf.get(), kBufferSize, callback.callback()); | |
7064 rv = callback.GetResult(rv); | |
7065 | |
7066 if (GetParam() == TRANSACTION_PHASE_AFTER_FIRST_READ && | |
7067 total_bytes_received == 0) | |
7068 http_transaction->StopCaching(); | |
7069 | |
7070 if (rv > 0) | |
7071 total_bytes_received += rv; | |
7072 | |
7073 if (network_transaction_started && | |
7074 GetParam() == TRANSACTION_PHASE_AFTER_NETWORK_READ) { | |
7075 http_transaction->StopCaching(); | |
7076 network_transaction_started = false; | |
7077 } | |
7078 } while (rv > 0); | |
7079 | |
7080 // The only thing we can test right now. Ideally we would also verify that | |
hubbe
2015/07/16 15:56:12
This comment makes no sense to me.
Verify A, but c
asanka
2015/07/16 16:16:58
The comment is explaining why we aren't checking m
hubbe
2015/07/16 16:57:52
Yes, this is a much better explanation than what i
asanka
2015/07/16 17:57:00
Done.
| |
7081 // only a single network request was made etc. But that's not currently | |
7082 // possible since multiple network requests are being made. | |
7083 EXPECT_EQ(kTotalSize, total_bytes_received); | |
7084 } | |
7085 | |
6932 // Tests that we detect truncated resources from the net when there is | 7086 // Tests that we detect truncated resources from the net when there is |
6933 // a Content-Length header. | 7087 // a Content-Length header. |
6934 TEST(HttpCache, TruncatedByContentLength) { | 7088 TEST(HttpCache, TruncatedByContentLength) { |
6935 MockHttpCache cache; | 7089 MockHttpCache cache; |
6936 TestCompletionCallback callback; | 7090 TestCompletionCallback callback; |
6937 | 7091 |
6938 MockTransaction transaction(kSimpleGET_Transaction); | 7092 MockTransaction transaction(kSimpleGET_Transaction); |
6939 AddMockTransaction(&transaction); | 7093 AddMockTransaction(&transaction); |
6940 transaction.response_headers = "Cache-Control: max-age=10000\n" | 7094 transaction.response_headers = "Cache-Control: max-age=10000\n" |
6941 "Content-Length: 100\n"; | 7095 "Content-Length: 100\n"; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7526 EXPECT_EQ(1, cache.disk_cache()->open_count()); | 7680 EXPECT_EQ(1, cache.disk_cache()->open_count()); |
7527 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 7681 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
7528 EXPECT_TRUE(response_info.was_cached); | 7682 EXPECT_TRUE(response_info.was_cached); |
7529 | 7683 |
7530 // The new SSL state is reported. | 7684 // The new SSL state is reported. |
7531 EXPECT_EQ(status2, response_info.ssl_info.connection_status); | 7685 EXPECT_EQ(status2, response_info.ssl_info.connection_status); |
7532 EXPECT_TRUE(cert2->Equals(response_info.ssl_info.cert.get())); | 7686 EXPECT_TRUE(cert2->Equals(response_info.ssl_info.cert.get())); |
7533 } | 7687 } |
7534 | 7688 |
7535 } // namespace net | 7689 } // namespace net |
OLD | NEW |