| Index: net/http/http_cache_unittest.cc
|
| diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
|
| index b03f827337eb47f82034b26ad80135a5aad60120..32dd987545c8a514dc7c623a2622d1473a91b5ee 100644
|
| --- a/net/http/http_cache_unittest.cc
|
| +++ b/net/http/http_cache_unittest.cc
|
| @@ -89,8 +89,7 @@ class DeleteCacheCompletionCallback : public net::TestCompletionCallbackBase {
|
| explicit DeleteCacheCompletionCallback(MockHttpCache* cache)
|
| : cache_(cache),
|
| callback_(base::Bind(&DeleteCacheCompletionCallback::OnComplete,
|
| - base::Unretained(this))) {
|
| - }
|
| + base::Unretained(this))) {}
|
|
|
| const net::CompletionCallback& callback() const { return callback_; }
|
|
|
| @@ -167,16 +166,26 @@ void RunTransactionTestWithRequest(net::HttpCache* cache,
|
| const MockTransaction& trans_info,
|
| const MockHttpRequest& request,
|
| net::HttpResponseInfo* response_info) {
|
| - RunTransactionTestBase(cache, trans_info, request, response_info,
|
| - net::BoundNetLog(), NULL, NULL);
|
| + RunTransactionTestBase(cache,
|
| + trans_info,
|
| + request,
|
| + response_info,
|
| + net::BoundNetLog(),
|
| + NULL,
|
| + NULL);
|
| }
|
|
|
| void RunTransactionTestAndGetTiming(net::HttpCache* cache,
|
| const MockTransaction& trans_info,
|
| const net::BoundNetLog& log,
|
| net::LoadTimingInfo* load_timing_info) {
|
| - RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info),
|
| - NULL, log, load_timing_info, NULL);
|
| + RunTransactionTestBase(cache,
|
| + trans_info,
|
| + MockHttpRequest(trans_info),
|
| + NULL,
|
| + log,
|
| + load_timing_info,
|
| + NULL);
|
| }
|
|
|
| void RunTransactionTest(net::HttpCache* cache,
|
| @@ -187,8 +196,8 @@ void RunTransactionTest(net::HttpCache* cache,
|
| void RunTransactionTestWithResponseInfo(net::HttpCache* cache,
|
| const MockTransaction& trans_info,
|
| net::HttpResponseInfo* response) {
|
| - RunTransactionTestWithRequest(cache, trans_info, MockHttpRequest(trans_info),
|
| - response);
|
| + RunTransactionTestWithRequest(
|
| + cache, trans_info, MockHttpRequest(trans_info), response);
|
| }
|
|
|
| void RunTransactionTestWithResponseInfoAndGetTiming(
|
| @@ -197,8 +206,13 @@ void RunTransactionTestWithResponseInfoAndGetTiming(
|
| net::HttpResponseInfo* response,
|
| const net::BoundNetLog& log,
|
| net::LoadTimingInfo* load_timing_info) {
|
| - RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info),
|
| - response, log, load_timing_info, NULL);
|
| + RunTransactionTestBase(cache,
|
| + trans_info,
|
| + MockHttpRequest(trans_info),
|
| + response,
|
| + log,
|
| + load_timing_info,
|
| + NULL);
|
| }
|
|
|
| void RunTransactionTestWithResponse(net::HttpCache* cache,
|
| @@ -216,8 +230,13 @@ void RunTransactionTestWithResponseAndGetTiming(
|
| const net::BoundNetLog& log,
|
| net::LoadTimingInfo* load_timing_info) {
|
| net::HttpResponseInfo response;
|
| - RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info),
|
| - &response, log, load_timing_info, NULL);
|
| + RunTransactionTestBase(cache,
|
| + trans_info,
|
| + MockHttpRequest(trans_info),
|
| + &response,
|
| + log,
|
| + load_timing_info,
|
| + NULL);
|
| response.headers->GetNormalizedHeaders(response_headers);
|
| }
|
|
|
| @@ -225,9 +244,7 @@ void RunTransactionTestWithResponseAndGetTiming(
|
| // no-store header can be included on demand.
|
| class FastTransactionServer {
|
| public:
|
| - FastTransactionServer() {
|
| - no_store = false;
|
| - }
|
| + FastTransactionServer() { no_store = false; }
|
| ~FastTransactionServer() {}
|
|
|
| void set_no_store(bool value) { no_store = value; }
|
| @@ -247,20 +264,13 @@ class FastTransactionServer {
|
| bool FastTransactionServer::no_store;
|
|
|
| const MockTransaction kFastNoStoreGET_Transaction = {
|
| - "http://www.google.com/nostore",
|
| - "GET",
|
| - base::Time(),
|
| - "",
|
| - net::LOAD_VALIDATE_CACHE,
|
| - "HTTP/1.1 200 OK",
|
| - "Cache-Control: max-age=10000\n",
|
| - base::Time(),
|
| - "<html><body>Google Blah Blah</body></html>",
|
| - TEST_MODE_SYNC_NET_START,
|
| - &FastTransactionServer::FastNoStoreHandler,
|
| - 0,
|
| - net::OK
|
| -};
|
| + "http://www.google.com/nostore", "GET",
|
| + base::Time(), "",
|
| + net::LOAD_VALIDATE_CACHE, "HTTP/1.1 200 OK",
|
| + "Cache-Control: max-age=10000\n", base::Time(),
|
| + "<html><body>Google Blah Blah</body></html>", TEST_MODE_SYNC_NET_START,
|
| + &FastTransactionServer::FastNoStoreHandler, 0,
|
| + net::OK};
|
|
|
| // This class provides a handler for kRangeGET_TransactionOK so that the range
|
| // request can be served on demand.
|
| @@ -342,8 +352,8 @@ void RangeTransactionServer::RangeHandler(const net::HttpRequestInfo* request,
|
|
|
| std::vector<net::HttpByteRange> ranges;
|
| std::string range_header;
|
| - if (!request->extra_headers.GetHeader(
|
| - net::HttpRequestHeaders::kRange, &range_header) ||
|
| + if (!request->extra_headers.GetHeader(net::HttpRequestHeaders::kRange,
|
| + &range_header) ||
|
| !net::HttpUtil::ParseRangeHeader(range_header, &ranges) || bad_200_ ||
|
| ranges.size() != 1) {
|
| // This is not a byte range request. We return 200.
|
| @@ -367,8 +377,8 @@ void RangeTransactionServer::RangeHandler(const net::HttpRequestInfo* request,
|
|
|
| EXPECT_LT(end, 80);
|
|
|
| - std::string content_range = base::StringPrintf(
|
| - "Content-Range: bytes %d-%d/80\n", start, end);
|
| + std::string content_range =
|
| + base::StringPrintf("Content-Range: bytes %d-%d/80\n", start, end);
|
| response_headers->append(content_range);
|
|
|
| if (!request->extra_headers.HasHeader("If-None-Match") || modified_) {
|
| @@ -379,8 +389,8 @@ void RangeTransactionServer::RangeHandler(const net::HttpRequestInfo* request,
|
| } else {
|
| EXPECT_EQ(9, (end - start) % 10);
|
| for (int block_start = start; block_start < end; block_start += 10) {
|
| - base::StringAppendF(&data, "rg: %02d-%02d ",
|
| - block_start, block_start + 9);
|
| + base::StringAppendF(
|
| + &data, "rg: %02d-%02d ", block_start, block_start + 9);
|
| }
|
| }
|
| *response_data = data;
|
| @@ -388,10 +398,11 @@ void RangeTransactionServer::RangeHandler(const net::HttpRequestInfo* request,
|
| if (end - start != 9) {
|
| // We also have to fix content-length.
|
| int len = end - start + 1;
|
| - std::string content_length = base::StringPrintf("Content-Length: %d\n",
|
| - len);
|
| + std::string content_length =
|
| + base::StringPrintf("Content-Length: %d\n", len);
|
| response_headers->replace(response_headers->find("Content-Length:"),
|
| - content_length.size(), content_length);
|
| + content_length.size(),
|
| + content_length);
|
| }
|
| } else {
|
| response_status->assign("HTTP/1.1 304 Not Modified");
|
| @@ -400,38 +411,28 @@ void RangeTransactionServer::RangeHandler(const net::HttpRequestInfo* request,
|
| }
|
|
|
| const MockTransaction kRangeGET_TransactionOK = {
|
| - "http://www.google.com/range",
|
| - "GET",
|
| - base::Time(),
|
| - "Range: bytes = 40-49\r\n"
|
| - EXTRA_HEADER,
|
| - net::LOAD_NORMAL,
|
| - "HTTP/1.1 206 Partial Content",
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 10\n",
|
| - base::Time(),
|
| - "rg: 40-49 ",
|
| - TEST_MODE_NORMAL,
|
| - &RangeTransactionServer::RangeHandler,
|
| - 0,
|
| - net::OK
|
| -};
|
| + "http://www.google.com/range", "GET", base::Time(),
|
| + "Range: bytes = 40-49\r\n" EXTRA_HEADER, net::LOAD_NORMAL,
|
| + "HTTP/1.1 206 Partial Content",
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 10\n",
|
| + base::Time(), "rg: 40-49 ", TEST_MODE_NORMAL,
|
| + &RangeTransactionServer::RangeHandler, 0, net::OK};
|
|
|
| // Verifies the response headers (|response|) match a partial content
|
| // response for the range starting at |start| and ending at |end|.
|
| void Verify206Response(std::string response, int start, int end) {
|
| - std::string raw_headers(net::HttpUtil::AssembleRawHeaders(response.data(),
|
| - response.size()));
|
| + std::string raw_headers(
|
| + net::HttpUtil::AssembleRawHeaders(response.data(), response.size()));
|
| scoped_refptr<net::HttpResponseHeaders> headers(
|
| new net::HttpResponseHeaders(raw_headers));
|
|
|
| ASSERT_EQ(206, headers->response_code());
|
|
|
| int64 range_start, range_end, object_size;
|
| - ASSERT_TRUE(
|
| - headers->GetContentRange(&range_start, &range_end, &object_size));
|
| + ASSERT_TRUE(headers->GetContentRange(&range_start, &range_end, &object_size));
|
| int64 content_length = headers->GetContentLength();
|
|
|
| int length = end - start + 1;
|
| @@ -444,11 +445,11 @@ void Verify206Response(std::string response, int start, int end) {
|
| void CreateTruncatedEntry(std::string raw_headers, MockHttpCache* cache) {
|
| // Create a disk cache entry that stores an incomplete resource.
|
| disk_cache::Entry* entry;
|
| - ASSERT_TRUE(cache->CreateBackendEntry(kRangeGET_TransactionOK.url, &entry,
|
| - NULL));
|
| + ASSERT_TRUE(
|
| + cache->CreateBackendEntry(kRangeGET_TransactionOK.url, &entry, NULL));
|
|
|
| - raw_headers = net::HttpUtil::AssembleRawHeaders(raw_headers.data(),
|
| - raw_headers.size());
|
| + raw_headers =
|
| + net::HttpUtil::AssembleRawHeaders(raw_headers.data(), raw_headers.size());
|
|
|
| net::HttpResponseInfo response;
|
| response.response_time = base::Time::Now();
|
| @@ -458,8 +459,8 @@ void CreateTruncatedEntry(std::string raw_headers, MockHttpCache* cache) {
|
| EXPECT_TRUE(MockHttpCache::WriteResponseInfo(entry, &response, true, true));
|
|
|
| scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(100));
|
| - int len = static_cast<int>(base::strlcpy(buf->data(),
|
| - "rg: 00-09 rg: 10-19 ", 100));
|
| + int len =
|
| + static_cast<int>(base::strlcpy(buf->data(), "rg: 00-09 rg: 10-19 ", 100));
|
| net::TestCompletionCallback cb;
|
| int rv = entry->WriteData(1, 0, buf.get(), len, cb.callback(), true);
|
| EXPECT_EQ(len, cb.GetResult(rv));
|
| @@ -497,7 +498,8 @@ class FakeWebSocketHandshakeStreamCreateHelper
|
| public:
|
| virtual ~FakeWebSocketHandshakeStreamCreateHelper() {}
|
| virtual net::WebSocketHandshakeStreamBase* CreateBasicStream(
|
| - scoped_ptr<net::ClientSocketHandle> connect, bool using_proxy) OVERRIDE {
|
| + scoped_ptr<net::ClientSocketHandle> connect,
|
| + bool using_proxy) OVERRIDE {
|
| return NULL;
|
| }
|
| virtual net::WebSocketHandshakeStreamBase* CreateSpdyStream(
|
| @@ -527,14 +529,13 @@ bool ShouldIgnoreLogEntry(const net::CapturingNetLog::CapturedEntry& entry) {
|
| // Modifies |entries| to only include log entries created by the cache layer and
|
| // asserted on in these tests.
|
| void FilterLogEntries(net::CapturingNetLog::CapturedEntryList* entries) {
|
| - entries->erase(std::remove_if(entries->begin(), entries->end(),
|
| - &ShouldIgnoreLogEntry),
|
| - entries->end());
|
| + entries->erase(
|
| + std::remove_if(entries->begin(), entries->end(), &ShouldIgnoreLogEntry),
|
| + entries->end());
|
| }
|
|
|
| } // namespace
|
|
|
| -
|
| //-----------------------------------------------------------------------------
|
| // Tests.
|
|
|
| @@ -562,8 +563,10 @@ TEST(HttpCache, SimpleGET) {
|
| net::LoadTimingInfo load_timing_info;
|
|
|
| // Write to the cache.
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction,
|
| - log.bound(), &load_timing_info);
|
| + RunTransactionTestAndGetTiming(cache.http_cache(),
|
| + kSimpleGET_Transaction,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| EXPECT_EQ(0, cache.disk_cache()->open_count());
|
| @@ -580,8 +583,10 @@ TEST(HttpCache, SimpleGETNoDiskCache) {
|
| net::LoadTimingInfo load_timing_info;
|
|
|
| // Read from the network, and don't use the cache.
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction,
|
| - log.bound(), &load_timing_info);
|
| + RunTransactionTestAndGetTiming(cache.http_cache(),
|
| + kSimpleGET_Transaction,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| // Check that the NetLog was filled as expected.
|
| // (We attempted to both Open and Create entries, but both failed).
|
| @@ -746,8 +751,10 @@ TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Hit) {
|
| net::LoadTimingInfo load_timing_info;
|
|
|
| // Write to the cache.
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), kSimpleGET_Transaction,
|
| - log.bound(), &load_timing_info);
|
| + RunTransactionTestAndGetTiming(cache.http_cache(),
|
| + kSimpleGET_Transaction,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| // Check that the NetLog was filled as expected.
|
| net::CapturingNetLog::CapturedEntryList entries;
|
| @@ -780,8 +787,8 @@ TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Hit) {
|
|
|
| log.Clear();
|
|
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestAndGetTiming(
|
| + cache.http_cache(), transaction, log.bound(), &load_timing_info);
|
|
|
| // Check that the NetLog was filled as expected.
|
| log.GetEntries(&entries);
|
| @@ -874,8 +881,9 @@ TEST(HttpCache, SimpleGET_LoadPreferringCache_VaryMatch) {
|
| // Write to the cache.
|
| MockTransaction transaction(kSimpleGET_Transaction);
|
| transaction.request_headers = "Foo: bar\r\n";
|
| - transaction.response_headers = "Cache-Control: max-age=10000\n"
|
| - "Vary: Foo\n";
|
| + transaction.response_headers =
|
| + "Cache-Control: max-age=10000\n"
|
| + "Vary: Foo\n";
|
| AddMockTransaction(&transaction);
|
| RunTransactionTest(cache.http_cache(), transaction);
|
|
|
| @@ -896,8 +904,9 @@ TEST(HttpCache, SimpleGET_LoadPreferringCache_VaryMismatch) {
|
| // Write to the cache.
|
| MockTransaction transaction(kSimpleGET_Transaction);
|
| transaction.request_headers = "Foo: bar\r\n";
|
| - transaction.response_headers = "Cache-Control: max-age=10000\n"
|
| - "Vary: Foo\n";
|
| + transaction.response_headers =
|
| + "Cache-Control: max-age=10000\n"
|
| + "Vary: Foo\n";
|
| AddMockTransaction(&transaction);
|
| RunTransactionTest(cache.http_cache(), transaction);
|
|
|
| @@ -907,8 +916,8 @@ TEST(HttpCache, SimpleGET_LoadPreferringCache_VaryMismatch) {
|
| transaction.request_headers = "Foo: none\r\n";
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestAndGetTiming(
|
| + cache.http_cache(), transaction, log.bound(), &load_timing_info);
|
|
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| EXPECT_EQ(1, cache.disk_cache()->open_count());
|
| @@ -938,8 +947,8 @@ TEST(HttpCache, SimpleGET_CacheOverride_Network) {
|
| transaction.data = "Changed data.";
|
| AddMockTransaction(&transaction);
|
| net::HttpResponseInfo response_info;
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), transaction,
|
| - &response_info);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), transaction, &response_info);
|
|
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| EXPECT_FALSE(response_info.server_data_unavailable);
|
| @@ -1008,8 +1017,8 @@ TEST(HttpCache, SimpleGET_CacheOverride_NonOffline) {
|
| AddMockTransaction(&transaction);
|
|
|
| net::HttpResponseInfo response_info2;
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), transaction,
|
| - &response_info2);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), transaction, &response_info2);
|
|
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| EXPECT_FALSE(response_info2.server_data_unavailable);
|
| @@ -1059,8 +1068,8 @@ TEST(HttpCache, SimpleGET_NetworkAccessed_Network) {
|
|
|
| // write to the cache
|
| net::HttpResponseInfo response_info;
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction,
|
| - &response_info);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), kSimpleGET_Transaction, &response_info);
|
|
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| EXPECT_EQ(0, cache.disk_cache()->open_count());
|
| @@ -1082,8 +1091,8 @@ TEST(HttpCache, SimpleGET_NetworkAccessed_Cache) {
|
|
|
| // Re-run transaction; make sure we don't mark the network as accessed.
|
| net::HttpResponseInfo response_info;
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), transaction,
|
| - &response_info);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), transaction, &response_info);
|
|
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| EXPECT_FALSE(response_info.server_data_unavailable);
|
| @@ -1104,8 +1113,8 @@ TEST(HttpCache, SimpleGET_LoadBypassCache) {
|
| net::LoadTimingInfo load_timing_info;
|
|
|
| // Write to the cache.
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestAndGetTiming(
|
| + cache.http_cache(), transaction, log.bound(), &load_timing_info);
|
|
|
| // Check that the NetLog was filled as expected.
|
| net::CapturingNetLog::CapturedEntryList entries;
|
| @@ -1186,9 +1195,11 @@ TEST(HttpCache, SimpleGET_LoadValidateCache) {
|
| net::HttpResponseInfo response_info;
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestWithResponseInfoAndGetTiming(
|
| - cache.http_cache(), transaction, &response_info, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseInfoAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &response_info,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| EXPECT_EQ(1, cache.disk_cache()->open_count());
|
| @@ -1217,11 +1228,10 @@ TEST(HttpCache, SimpleGET_LoadValidateCache_Implicit) {
|
| EXPECT_EQ(1, cache.disk_cache()->create_count());
|
| }
|
|
|
| -static void PreserveRequestHeaders_Handler(
|
| - const net::HttpRequestInfo* request,
|
| - std::string* response_status,
|
| - std::string* response_headers,
|
| - std::string* response_data) {
|
| +static void PreserveRequestHeaders_Handler(const net::HttpRequestInfo* request,
|
| + std::string* response_status,
|
| + std::string* response_headers,
|
| + std::string* response_data) {
|
| EXPECT_TRUE(request->extra_headers.HasHeader(kExtraHeaderKey));
|
| }
|
|
|
| @@ -1254,8 +1264,7 @@ TEST(HttpCache, ConditionalizedGET_PreserveRequestHeaders) {
|
|
|
| MockTransaction transaction(kETagGET_Transaction);
|
| transaction.handler = PreserveRequestHeaders_Handler;
|
| - transaction.request_headers = "If-None-Match: \"foopy\"\r\n"
|
| - EXTRA_HEADER;
|
| + transaction.request_headers = "If-None-Match: \"foopy\"\r\n" EXTRA_HEADER;
|
| AddMockTransaction(&transaction);
|
|
|
| RunTransactionTest(cache.http_cache(), transaction);
|
| @@ -1282,8 +1291,8 @@ TEST(HttpCache, SimpleGET_ManyReaders) {
|
| ASSERT_EQ(net::OK, c->result);
|
| EXPECT_EQ(net::LOAD_STATE_IDLE, c->trans->GetLoadState());
|
|
|
| - c->result = c->trans->Start(
|
| - &request, c->callback.callback(), net::BoundNetLog());
|
| + c->result =
|
| + c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| }
|
|
|
| // All requests are waiting for the active entry.
|
| @@ -1374,8 +1383,7 @@ TEST(HttpCache, SimpleGET_RacingReaders) {
|
|
|
| // Now we have 2 active readers and two queued transactions.
|
|
|
| - EXPECT_EQ(net::LOAD_STATE_IDLE,
|
| - context_list[2]->trans->GetLoadState());
|
| + EXPECT_EQ(net::LOAD_STATE_IDLE, context_list[2]->trans->GetLoadState());
|
| EXPECT_EQ(net::LOAD_STATE_WAITING_FOR_CACHE,
|
| context_list[3]->trans->GetLoadState());
|
|
|
| @@ -1482,8 +1490,8 @@ TEST(HttpCache, FastNoStoreGET_DoneWithPending) {
|
| c->result = cache.CreateTransaction(&c->trans);
|
| ASSERT_EQ(net::OK, c->result);
|
|
|
| - c->result = c->trans->Start(
|
| - &request, c->callback.callback(), net::BoundNetLog());
|
| + c->result =
|
| + c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| }
|
|
|
| // Allow all requests to move from the Create queue to the active entry.
|
| @@ -1529,8 +1537,8 @@ TEST(HttpCache, SimpleGET_ManyWriters_CancelFirst) {
|
| c->result = cache.CreateTransaction(&c->trans);
|
| ASSERT_EQ(net::OK, c->result);
|
|
|
| - c->result = c->trans->Start(
|
| - &request, c->callback.callback(), net::BoundNetLog());
|
| + c->result =
|
| + c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| }
|
|
|
| // Allow all requests to move from the Create queue to the active entry.
|
| @@ -1589,8 +1597,8 @@ TEST(HttpCache, SimpleGET_ManyWriters_CancelCreate) {
|
| c->result = cache.CreateTransaction(&c->trans);
|
| ASSERT_EQ(net::OK, c->result);
|
|
|
| - c->result = c->trans->Start(
|
| - &request, c->callback.callback(), net::BoundNetLog());
|
| + c->result =
|
| + c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| }
|
|
|
| // The first request should be creating the disk cache entry and the others
|
| @@ -1640,8 +1648,8 @@ TEST(HttpCache, SimpleGET_CancelCreate) {
|
| c->result = cache.CreateTransaction(&c->trans);
|
| ASSERT_EQ(net::OK, c->result);
|
|
|
| - c->result = c->trans->Start(
|
| - &request, c->callback.callback(), net::BoundNetLog());
|
| + c->result =
|
| + c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| EXPECT_EQ(net::ERR_IO_PENDING, c->result);
|
|
|
| // Release the reference that the mock disk cache keeps for this entry, so
|
| @@ -1670,8 +1678,8 @@ TEST(HttpCache, SimpleGET_ManyWriters_BypassCache) {
|
| c->result = cache.CreateTransaction(&c->trans);
|
| ASSERT_EQ(net::OK, c->result);
|
|
|
| - c->result = c->trans->Start(
|
| - &request, c->callback.callback(), net::BoundNetLog());
|
| + c->result =
|
| + c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| }
|
|
|
| // The first request should be deleting the disk cache entry and the others
|
| @@ -1731,8 +1739,8 @@ TEST(HttpCache, SimpleGET_AbandonedCacheRead) {
|
| // Tests that we can delete the HttpCache and deal with queued transactions
|
| // ("waiting for the backend" as opposed to Active or Doomed entries).
|
| TEST(HttpCache, SimpleGET_ManyWriters_DeleteCache) {
|
| - scoped_ptr<MockHttpCache> cache(new MockHttpCache(
|
| - new MockBackendNoCbFactory()));
|
| + scoped_ptr<MockHttpCache> cache(
|
| + new MockHttpCache(new MockBackendNoCbFactory()));
|
|
|
| MockHttpRequest request(kSimpleGET_Transaction);
|
|
|
| @@ -1746,8 +1754,8 @@ TEST(HttpCache, SimpleGET_ManyWriters_DeleteCache) {
|
| c->result = cache->CreateTransaction(&c->trans);
|
| ASSERT_EQ(net::OK, c->result);
|
|
|
| - c->result = c->trans->Start(
|
| - &request, c->callback.callback(), net::BoundNetLog());
|
| + c->result =
|
| + c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| }
|
|
|
| // The first request should be creating the disk cache entry and the others
|
| @@ -1952,8 +1960,10 @@ TEST(HttpCache, TypicalGET_ConditionalRequest) {
|
| // in a conditional request.
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), kTypicalGET_Transaction,
|
| - log.bound(), &load_timing_info);
|
| + RunTransactionTestAndGetTiming(cache.http_cache(),
|
| + kTypicalGET_Transaction,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| EXPECT_EQ(1, cache.disk_cache()->open_count());
|
| @@ -1991,8 +2001,8 @@ TEST(HttpCache, ETagGET_ConditionalRequest_304) {
|
| transaction.handler = ETagGet_ConditionalRequest_Handler;
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestAndGetTiming(
|
| + cache.http_cache(), transaction, log.bound(), &load_timing_info);
|
|
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| EXPECT_EQ(1, cache.disk_cache()->open_count());
|
| @@ -2027,11 +2037,11 @@ void RevalidationServer::Handler(const net::HttpRequestInfo* request,
|
| std::string* response_headers,
|
| std::string* response_data) {
|
| if (request->extra_headers.HasHeader(net::HttpRequestHeaders::kIfNoneMatch))
|
| - s_etag_used_ = true;
|
| + s_etag_used_ = true;
|
|
|
| if (request->extra_headers.HasHeader(
|
| net::HttpRequestHeaders::kIfModifiedSince)) {
|
| - s_last_modified_used_ = true;
|
| + s_last_modified_used_ = true;
|
| }
|
|
|
| if (s_etag_used_ || s_last_modified_used_) {
|
| @@ -2066,8 +2076,8 @@ TEST(HttpCache, SimpleGET_LoadValidateCache_VaryMatch) {
|
| transaction.handler = server.Handler;
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestAndGetTiming(
|
| + cache.http_cache(), transaction, log.bound(), &load_timing_info);
|
|
|
| EXPECT_TRUE(server.EtagUsed());
|
| EXPECT_TRUE(server.LastModifiedUsed());
|
| @@ -2100,8 +2110,8 @@ TEST(HttpCache, SimpleGET_LoadValidateCache_VaryMismatch) {
|
| transaction.request_headers = "Foo: none\r\n";
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestAndGetTiming(
|
| + cache.http_cache(), transaction, log.bound(), &load_timing_info);
|
|
|
| EXPECT_TRUE(server.EtagUsed());
|
| EXPECT_FALSE(server.LastModifiedUsed());
|
| @@ -2133,8 +2143,8 @@ TEST(HttpCache, SimpleGET_LoadDontValidateCache_VaryMismatch) {
|
| transaction.request_headers = "Foo: none\r\n";
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestAndGetTiming(cache.http_cache(), transaction, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestAndGetTiming(
|
| + cache.http_cache(), transaction, log.bound(), &load_timing_info);
|
|
|
| EXPECT_FALSE(server.EtagUsed());
|
| EXPECT_FALSE(server.LastModifiedUsed());
|
| @@ -2264,22 +2274,20 @@ static void ConditionalizedRequestUpdatesCacheHelper(
|
| const char* kUrl = "http://foobar.com/main.css";
|
|
|
| // Junk network response.
|
| - static const Response kUnexpectedResponse = {
|
| - "HTTP/1.1 500 Unexpected",
|
| - "Server: unexpected_header",
|
| - "unexpected body"
|
| - };
|
| + static const Response kUnexpectedResponse = {"HTTP/1.1 500 Unexpected",
|
| + "Server: unexpected_header",
|
| + "unexpected body"};
|
|
|
| // We will control the network layer's responses for |kUrl| using
|
| // |mock_network_response|.
|
| - MockTransaction mock_network_response = { 0 };
|
| + MockTransaction mock_network_response = {0};
|
| mock_network_response.url = kUrl;
|
| AddMockTransaction(&mock_network_response);
|
|
|
| // Request |kUrl| for the first time. It should hit the network and
|
| // receive |kNetResponse1|, which it saves into the HTTP cache.
|
|
|
| - MockTransaction request = { 0 };
|
| + MockTransaction request = {0};
|
| request.url = kUrl;
|
| request.method = "GET";
|
| request.request_headers = "";
|
| @@ -2358,19 +2366,17 @@ static void ConditionalizedRequestUpdatesCacheHelper(
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache1) {
|
| // First network response for |kUrl|.
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| - "body2"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| + "body2"};
|
|
|
| const char* extra_headers =
|
| "If-Modified-Since: Wed, 06 Feb 2008 22:38:21 GMT\r\n";
|
| @@ -2384,21 +2390,19 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache1) {
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache2) {
|
| // First network response for |kUrl|.
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Etag: \"ETAG1\"\n"
|
| - "Expires: Wed, 7 Sep 2033 21:46:42 GMT\n", // Should never expire.
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Etag: \"ETAG1\"\n"
|
| + "Expires: Wed, 7 Sep 2033 21:46:42 GMT\n", // Should never expire.
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Etag: \"ETAG2\"\n"
|
| - "Expires: Wed, 7 Sep 2033 21:46:42 GMT\n", // Should never expire.
|
| - "body2"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Etag: \"ETAG2\"\n"
|
| + "Expires: Wed, 7 Sep 2033 21:46:42 GMT\n", // Should never expire.
|
| + "body2"};
|
|
|
| const char* extra_headers = "If-None-Match: \"ETAG1\"\r\n";
|
|
|
| @@ -2412,29 +2416,26 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache2) {
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache3) {
|
| // First network response for |kUrl|.
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Server: server1\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Server: server1\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 304 Not Modified",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Server: server2\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - ""
|
| - };
|
| + "HTTP/1.1 304 Not Modified",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Server: server2\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + ""};
|
|
|
| static const Response kCachedResponse2 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Server: server2\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Server: server2\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| const char* extra_headers =
|
| "If-Modified-Since: Wed, 06 Feb 2008 22:38:21 GMT\r\n";
|
| @@ -2452,22 +2453,21 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache4) {
|
| const char* kUrl = "http://foobar.com/main.css";
|
|
|
| static const Response kNetResponse = {
|
| - "HTTP/1.1 304 Not Modified",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - ""
|
| - };
|
| + "HTTP/1.1 304 Not Modified",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + ""};
|
|
|
| const char* kExtraRequestHeaders =
|
| "If-Modified-Since: Wed, 06 Feb 2008 22:38:21 GMT\r\n";
|
|
|
| // We will control the network layer's responses for |kUrl| using
|
| // |mock_network_response|.
|
| - MockTransaction mock_network_response = { 0 };
|
| + MockTransaction mock_network_response = {0};
|
| mock_network_response.url = kUrl;
|
| AddMockTransaction(&mock_network_response);
|
|
|
| - MockTransaction request = { 0 };
|
| + MockTransaction request = {0};
|
| request.url = kUrl;
|
| request.method = "GET";
|
| request.request_headers = kExtraRequestHeaders;
|
| @@ -2496,22 +2496,21 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache5) {
|
| const char* kUrl = "http://foobar.com/main.css";
|
|
|
| static const Response kNetResponse = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "foobar!!!"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "foobar!!!"};
|
|
|
| const char* kExtraRequestHeaders =
|
| "If-Modified-Since: Wed, 06 Feb 2008 22:38:21 GMT\r\n";
|
|
|
| // We will control the network layer's responses for |kUrl| using
|
| // |mock_network_response|.
|
| - MockTransaction mock_network_response = { 0 };
|
| + MockTransaction mock_network_response = {0};
|
| mock_network_response.url = kUrl;
|
| AddMockTransaction(&mock_network_response);
|
|
|
| - MockTransaction request = { 0 };
|
| + MockTransaction request = {0};
|
| request.url = kUrl;
|
| request.method = "GET";
|
| request.request_headers = kExtraRequestHeaders;
|
| @@ -2537,21 +2536,19 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache5) {
|
| // (the if-modified-since date is 2 days AFTER the cache's modification date).
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache6) {
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Server: server1\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Server: server1\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 304 Not Modified",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Server: server2\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - ""
|
| - };
|
| + "HTTP/1.1 304 Not Modified",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Server: server2\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + ""};
|
|
|
| // This is two days in the future from the original response's last-modified
|
| // date!
|
| @@ -2567,21 +2564,19 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache6) {
|
| // response (304) to update the cache.
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache7) {
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Etag: \"Foo1\"\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Etag: \"Foo1\"\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 304 Not Modified",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Etag: \"Foo2\"\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - ""
|
| - };
|
| + "HTTP/1.1 304 Not Modified",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Etag: \"Foo2\"\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + ""};
|
|
|
| // Different etag from original response.
|
| const char* kExtraRequestHeaders = "If-None-Match: \"Foo2\"\r\n";
|
| @@ -2594,21 +2589,19 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache7) {
|
| // and if-modified-since updates the cache.
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache8) {
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Etag: \"Foo1\"\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Etag: \"Foo1\"\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Etag: \"Foo2\"\n"
|
| - "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| - "body2"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Etag: \"Foo2\"\n"
|
| + "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| + "body2"};
|
|
|
| const char* kExtraRequestHeaders =
|
| "If-Modified-Since: Wed, 06 Feb 2008 22:38:21 GMT\r\n"
|
| @@ -2622,21 +2615,19 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache8) {
|
| // and if-modified-since does not update the cache with only one match.
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache9) {
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Etag: \"Foo1\"\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Etag: \"Foo1\"\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Etag: \"Foo2\"\n"
|
| - "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| - "body2"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Etag: \"Foo2\"\n"
|
| + "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| + "body2"};
|
|
|
| // The etag doesn't match what we have stored.
|
| const char* kExtraRequestHeaders =
|
| @@ -2651,21 +2642,19 @@ TEST(HttpCache, ConditionalizedRequestUpdatesCache9) {
|
| // and if-modified-since does not update the cache with only one match.
|
| TEST(HttpCache, ConditionalizedRequestUpdatesCache10) {
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Etag: \"Foo1\"\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - "body1"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Etag: \"Foo1\"\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + "body1"};
|
|
|
| // Second network response for |kUrl|.
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Etag: \"Foo2\"\n"
|
| - "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| - "body2"
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Etag: \"Foo2\"\n"
|
| + "Last-Modified: Fri, 03 Jul 2009 02:14:27 GMT\n",
|
| + "body2"};
|
|
|
| // The modification date doesn't match what we have stored.
|
| const char* kExtraRequestHeaders =
|
| @@ -3274,9 +3263,8 @@ TEST(HttpCache, RangeGET_SkipsCache2) {
|
| MockHttpCache cache;
|
|
|
| MockTransaction transaction(kRangeGET_Transaction);
|
| - transaction.request_headers = "If-None-Match: foo\r\n"
|
| - EXTRA_HEADER
|
| - "Range: bytes = 40-49\r\n";
|
| + transaction.request_headers =
|
| + "If-None-Match: foo\r\n" EXTRA_HEADER "Range: bytes = 40-49\r\n";
|
| RunTransactionTest(cache.http_cache(), transaction);
|
|
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -3284,8 +3272,7 @@ TEST(HttpCache, RangeGET_SkipsCache2) {
|
| EXPECT_EQ(0, cache.disk_cache()->create_count());
|
|
|
| transaction.request_headers =
|
| - "If-Modified-Since: Wed, 28 Nov 2007 00:45:20 GMT\r\n"
|
| - EXTRA_HEADER
|
| + "If-Modified-Since: Wed, 28 Nov 2007 00:45:20 GMT\r\n" EXTRA_HEADER
|
| "Range: bytes = 40-49\r\n";
|
| RunTransactionTest(cache.http_cache(), transaction);
|
|
|
| @@ -3293,9 +3280,8 @@ TEST(HttpCache, RangeGET_SkipsCache2) {
|
| EXPECT_EQ(0, cache.disk_cache()->open_count());
|
| EXPECT_EQ(0, cache.disk_cache()->create_count());
|
|
|
| - transaction.request_headers = "If-Range: bla\r\n"
|
| - EXTRA_HEADER
|
| - "Range: bytes = 40-49\r\n";
|
| + transaction.request_headers =
|
| + "If-Range: bla\r\n" EXTRA_HEADER "Range: bytes = 40-49\r\n";
|
| RunTransactionTest(cache.http_cache(), transaction);
|
|
|
| EXPECT_EQ(3, cache.network_layer()->transaction_count());
|
| @@ -3352,8 +3338,9 @@ TEST(HttpCache, RangeGET_NoStrongValidators) {
|
| // Attempt to write to the cache (40-49).
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| AddMockTransaction(&transaction);
|
| - transaction.response_headers = "Content-Length: 10\n"
|
| - "ETag: w/\"foo\"\n";
|
| + transaction.response_headers =
|
| + "Content-Length: 10\n"
|
| + "ETag: w/\"foo\"\n";
|
| RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| @@ -3362,8 +3349,8 @@ TEST(HttpCache, RangeGET_NoStrongValidators) {
|
| EXPECT_EQ(1, cache.disk_cache()->create_count());
|
|
|
| // Now verify that there's no cached data.
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| @@ -3381,9 +3368,10 @@ TEST(HttpCache, RangeGET_NoContentLength) {
|
| // Attempt to write to the cache (40-49).
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| AddMockTransaction(&transaction);
|
| - transaction.response_headers = "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Range: bytes 40-49/80\n";
|
| + transaction.response_headers =
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Range: bytes 40-49/80\n";
|
| transaction.handler = NULL;
|
| RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
|
|
|
| @@ -3393,8 +3381,8 @@ TEST(HttpCache, RangeGET_NoContentLength) {
|
|
|
| // Now verify that there's no cached data.
|
| transaction.handler = &RangeTransactionServer::RangeHandler;
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| @@ -3412,8 +3400,8 @@ TEST(HttpCache, RangeGET_OK) {
|
| std::string headers;
|
|
|
| // Write to the cache (40-49).
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -3421,8 +3409,8 @@ TEST(HttpCache, RangeGET_OK) {
|
| EXPECT_EQ(1, cache.disk_cache()->create_count());
|
|
|
| // Read from the cache (40-49).
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -3451,9 +3439,11 @@ TEST(HttpCache, RangeGET_OK) {
|
| transaction.data = "rg: 20-29 rg: 30-39 rg: 40-49 rg: 50-59 ";
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| Verify206Response(headers, 20, 59);
|
| EXPECT_EQ(4, cache.network_layer()->transaction_count());
|
| @@ -3483,9 +3473,8 @@ TEST(HttpCache, RangeGET_SparseNotImplemented) {
|
| // Verify that we added the entry.
|
| disk_cache::Entry* entry;
|
| net::TestCompletionCallback cb;
|
| - int rv = cache.disk_cache()->OpenEntry(transaction.url,
|
| - &entry,
|
| - cb.callback());
|
| + int rv =
|
| + cache.disk_cache()->OpenEntry(transaction.url, &entry, cb.callback());
|
| ASSERT_EQ(net::OK, cb.GetResult(rv));
|
| EXPECT_EQ(1, cache.disk_cache()->open_count());
|
| entry->Close();
|
| @@ -3504,9 +3493,7 @@ TEST(HttpCache, RangeGET_SparseNotImplemented) {
|
| // if it was re-created later, so this effectively checks that the old data is
|
| // gone.
|
| disk_cache::Entry* entry2;
|
| - rv = cache.disk_cache()->OpenEntry(transaction2.url,
|
| - &entry2,
|
| - cb.callback());
|
| + rv = cache.disk_cache()->OpenEntry(transaction2.url, &entry2, cb.callback());
|
| ASSERT_EQ(net::ERR_CACHE_OPEN_FAILURE, cb.GetResult(rv));
|
| RemoveMockTransaction(&transaction2);
|
| }
|
| @@ -3529,9 +3516,8 @@ TEST(HttpCache, RangeGET_SparseNotImplementedOnEmptyCache) {
|
| // gone as a result of a failed range write.
|
| disk_cache::Entry* entry;
|
| net::TestCompletionCallback cb;
|
| - int rv = cache.disk_cache()->OpenEntry(transaction.url,
|
| - &entry,
|
| - cb.callback());
|
| + int rv =
|
| + cache.disk_cache()->OpenEntry(transaction.url, &entry, cb.callback());
|
| ASSERT_EQ(net::ERR_CACHE_OPEN_FAILURE, cb.GetResult(rv));
|
| RemoveMockTransaction(&transaction);
|
| }
|
| @@ -3583,9 +3569,11 @@ TEST(HttpCache, RangeGET_SyncOK) {
|
| transaction.data = "rg: 20-29 rg: 30-39 rg: 40-49 rg: 50-59 ";
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| Verify206Response(headers, 20, 59);
|
| EXPECT_EQ(4, cache.network_layer()->transaction_count());
|
| @@ -3620,9 +3608,11 @@ TEST(HttpCache, RangeGET_Revalidate1) {
|
| // Read from the cache (40-49).
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -3632,9 +3622,11 @@ TEST(HttpCache, RangeGET_Revalidate1) {
|
|
|
| // Read again forcing the revalidation.
|
| transaction.load_flags |= net::LOAD_VALIDATE_CACHE;
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| @@ -3684,8 +3676,8 @@ TEST(HttpCache, RangeGET_304) {
|
| std::string headers;
|
|
|
| // Write to the cache (40-49).
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -3714,8 +3706,8 @@ TEST(HttpCache, RangeGET_ModifiedResult) {
|
| std::string headers;
|
|
|
| // Write to the cache (40-49).
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -3879,9 +3871,11 @@ TEST(HttpCache, GET_Previous206) {
|
| net::LoadTimingInfo load_timing_info;
|
|
|
| // Write to the cache (40-49).
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), kRangeGET_TransactionOK, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + kRangeGET_TransactionOK,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -3892,11 +3886,14 @@ TEST(HttpCache, GET_Previous206) {
|
| // Write and read from the cache (0-79), when not asked for a range.
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| transaction.request_headers = EXTRA_HEADER;
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| EXPECT_EQ(0U, headers.find("HTTP/1.1 200 OK\n"));
|
| EXPECT_EQ(3, cache.network_layer()->transaction_count());
|
| @@ -3921,18 +3918,22 @@ TEST(HttpCache, GET_Previous206_NotModified) {
|
| // Write to the cache (0-9).
|
| transaction.request_headers = "Range: bytes = 0-9\r\n" EXTRA_HEADER;
|
| transaction.data = "rg: 00-09 ";
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
| Verify206Response(headers, 0, 9);
|
| TestLoadTimingNetworkRequest(load_timing_info);
|
|
|
| // Write to the cache (70-79).
|
| transaction.request_headers = "Range: bytes = 70-79\r\n" EXTRA_HEADER;
|
| transaction.data = "rg: 70-79 ";
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
| Verify206Response(headers, 70, 79);
|
|
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| @@ -3943,11 +3944,14 @@ TEST(HttpCache, GET_Previous206_NotModified) {
|
| // Read from the cache (0-9), write and read from cache (10 - 79).
|
| transaction.load_flags |= net::LOAD_VALIDATE_CACHE;
|
| transaction.request_headers = "Foo: bar\r\n" EXTRA_HEADER;
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| EXPECT_EQ(0U, headers.find("HTTP/1.1 200 OK\n"));
|
| EXPECT_EQ(4, cache.network_layer()->transaction_count());
|
| @@ -3988,9 +3992,11 @@ TEST(HttpCache, GET_Previous206_NewContent) {
|
| handler.set_modified(true);
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), transaction2, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + transaction2,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| EXPECT_EQ(0U, headers.find("HTTP/1.1 200 OK\n"));
|
| EXPECT_EQ(3, cache.network_layer()->transaction_count());
|
| @@ -4011,22 +4017,22 @@ TEST(HttpCache, GET_Previous206_NotSparse) {
|
|
|
| // Create a disk cache entry that stores 206 headers while not being sparse.
|
| disk_cache::Entry* entry;
|
| - ASSERT_TRUE(cache.CreateBackendEntry(kSimpleGET_Transaction.url, &entry,
|
| - NULL));
|
| + ASSERT_TRUE(
|
| + cache.CreateBackendEntry(kSimpleGET_Transaction.url, &entry, NULL));
|
|
|
| std::string raw_headers(kRangeGET_TransactionOK.status);
|
| raw_headers.append("\n");
|
| raw_headers.append(kRangeGET_TransactionOK.response_headers);
|
| - raw_headers = net::HttpUtil::AssembleRawHeaders(raw_headers.data(),
|
| - raw_headers.size());
|
| + raw_headers =
|
| + net::HttpUtil::AssembleRawHeaders(raw_headers.data(), raw_headers.size());
|
|
|
| net::HttpResponseInfo response;
|
| response.headers = new net::HttpResponseHeaders(raw_headers);
|
| EXPECT_TRUE(MockHttpCache::WriteResponseInfo(entry, &response, true, false));
|
|
|
| scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(500));
|
| - int len = static_cast<int>(base::strlcpy(buf->data(),
|
| - kRangeGET_TransactionOK.data, 500));
|
| + int len = static_cast<int>(
|
| + base::strlcpy(buf->data(), kRangeGET_TransactionOK.data, 500));
|
| net::TestCompletionCallback cb;
|
| int rv = entry->WriteData(1, 0, buf.get(), len, cb.callback(), true);
|
| EXPECT_EQ(len, cb.GetResult(rv));
|
| @@ -4036,9 +4042,11 @@ TEST(HttpCache, GET_Previous206_NotSparse) {
|
| std::string headers;
|
| net::CapturingBoundNetLog log;
|
| net::LoadTimingInfo load_timing_info;
|
| - RunTransactionTestWithResponseAndGetTiming(
|
| - cache.http_cache(), kSimpleGET_Transaction, &headers, log.bound(),
|
| - &load_timing_info);
|
| + RunTransactionTestWithResponseAndGetTiming(cache.http_cache(),
|
| + kSimpleGET_Transaction,
|
| + &headers,
|
| + log.bound(),
|
| + &load_timing_info);
|
|
|
| // We are expecting a 200.
|
| std::string expected_headers(kSimpleGET_Transaction.status);
|
| @@ -4059,22 +4067,22 @@ TEST(HttpCache, RangeGET_Previous206_NotSparse_2) {
|
|
|
| // Create a disk cache entry that stores 206 headers while not being sparse.
|
| disk_cache::Entry* entry;
|
| - ASSERT_TRUE(cache.CreateBackendEntry(kRangeGET_TransactionOK.url, &entry,
|
| - NULL));
|
| + ASSERT_TRUE(
|
| + cache.CreateBackendEntry(kRangeGET_TransactionOK.url, &entry, NULL));
|
|
|
| std::string raw_headers(kRangeGET_TransactionOK.status);
|
| raw_headers.append("\n");
|
| raw_headers.append(kRangeGET_TransactionOK.response_headers);
|
| - raw_headers = net::HttpUtil::AssembleRawHeaders(raw_headers.data(),
|
| - raw_headers.size());
|
| + raw_headers =
|
| + net::HttpUtil::AssembleRawHeaders(raw_headers.data(), raw_headers.size());
|
|
|
| net::HttpResponseInfo response;
|
| response.headers = new net::HttpResponseHeaders(raw_headers);
|
| EXPECT_TRUE(MockHttpCache::WriteResponseInfo(entry, &response, true, false));
|
|
|
| scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(500));
|
| - int len = static_cast<int>(base::strlcpy(buf->data(),
|
| - kRangeGET_TransactionOK.data, 500));
|
| + int len = static_cast<int>(
|
| + base::strlcpy(buf->data(), kRangeGET_TransactionOK.data, 500));
|
| net::TestCompletionCallback cb;
|
| int rv = entry->WriteData(1, 0, buf.get(), len, cb.callback(), true);
|
| EXPECT_EQ(len, cb.GetResult(rv));
|
| @@ -4082,8 +4090,8 @@ TEST(HttpCache, RangeGET_Previous206_NotSparse_2) {
|
|
|
| // Now see that we don't use the stored entry.
|
| std::string headers;
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| // We are expecting a 206.
|
| Verify206Response(headers, 40, 49);
|
| @@ -4100,23 +4108,23 @@ TEST(HttpCache, GET_Previous206_NotValidation) {
|
|
|
| // Create a disk cache entry that stores 206 headers.
|
| disk_cache::Entry* entry;
|
| - ASSERT_TRUE(cache.CreateBackendEntry(kSimpleGET_Transaction.url, &entry,
|
| - NULL));
|
| + ASSERT_TRUE(
|
| + cache.CreateBackendEntry(kSimpleGET_Transaction.url, &entry, NULL));
|
|
|
| // Make sure that the headers cannot be validated with the server.
|
| std::string raw_headers(kRangeGET_TransactionOK.status);
|
| raw_headers.append("\n");
|
| raw_headers.append("Content-Length: 80\n");
|
| - raw_headers = net::HttpUtil::AssembleRawHeaders(raw_headers.data(),
|
| - raw_headers.size());
|
| + raw_headers =
|
| + net::HttpUtil::AssembleRawHeaders(raw_headers.data(), raw_headers.size());
|
|
|
| net::HttpResponseInfo response;
|
| response.headers = new net::HttpResponseHeaders(raw_headers);
|
| EXPECT_TRUE(MockHttpCache::WriteResponseInfo(entry, &response, true, false));
|
|
|
| scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(500));
|
| - int len = static_cast<int>(base::strlcpy(buf->data(),
|
| - kRangeGET_TransactionOK.data, 500));
|
| + int len = static_cast<int>(
|
| + base::strlcpy(buf->data(), kRangeGET_TransactionOK.data, 500));
|
| net::TestCompletionCallback cb;
|
| int rv = entry->WriteData(1, 0, buf.get(), len, cb.callback(), true);
|
| EXPECT_EQ(len, cb.GetResult(rv));
|
| @@ -4124,8 +4132,8 @@ TEST(HttpCache, GET_Previous206_NotValidation) {
|
|
|
| // Now see that we don't use the stored entry.
|
| std::string headers;
|
| - RunTransactionTestWithResponse(cache.http_cache(), kSimpleGET_Transaction,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kSimpleGET_Transaction, &headers);
|
|
|
| // We are expecting a 200.
|
| std::string expected_headers(kSimpleGET_Transaction.status);
|
| @@ -4144,8 +4152,9 @@ TEST(HttpCache, RangeGET_Previous200) {
|
| // Store the whole thing with status 200.
|
| MockTransaction transaction(kTypicalGET_Transaction);
|
| transaction.url = kRangeGET_TransactionOK.url;
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| AddMockTransaction(&transaction);
|
| RunTransactionTest(cache.http_cache(), transaction);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -4254,8 +4263,8 @@ TEST(HttpCache, RangeGET_MoreThanCurrentSize) {
|
| std::string headers;
|
|
|
| // Write to the cache (40-49).
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -4428,8 +4437,9 @@ TEST(HttpCache, RangeGET_InvalidResponse1) {
|
|
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| transaction.handler = NULL;
|
| - transaction.response_headers = "Content-Range: bytes 40-49/45\n"
|
| - "Content-Length: 10\n";
|
| + transaction.response_headers =
|
| + "Content-Range: bytes 40-49/45\n"
|
| + "Content-Length: 10\n";
|
| AddMockTransaction(&transaction);
|
| RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
|
|
|
| @@ -4456,8 +4466,9 @@ TEST(HttpCache, RangeGET_InvalidResponse2) {
|
|
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| transaction.handler = NULL;
|
| - transaction.response_headers = "Content-Range: bytes 40-49/80\n"
|
| - "Content-Length: 20\n";
|
| + transaction.response_headers =
|
| + "Content-Range: bytes 40-49/80\n"
|
| + "Content-Length: 20\n";
|
| AddMockTransaction(&transaction);
|
| RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
|
|
|
| @@ -4502,8 +4513,8 @@ TEST(HttpCache, RangeGET_InvalidResponse3) {
|
|
|
| // This transaction will report a resource size of 80 bytes, and we think it's
|
| // 160 so we should ignore the response.
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(2, cache.network_layer()->transaction_count());
|
| @@ -4532,8 +4543,8 @@ TEST(HttpCache, RangeGET_LargeValues) {
|
|
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| transaction.handler = NULL;
|
| - transaction.request_headers = "Range: bytes = 4294967288-4294967297\r\n"
|
| - EXTRA_HEADER;
|
| + transaction.request_headers =
|
| + "Range: bytes = 4294967288-4294967297\r\n" EXTRA_HEADER;
|
| transaction.response_headers =
|
| "ETag: \"foo\"\n"
|
| "Content-Range: bytes 4294967288-4294967297/4294967299\n"
|
| @@ -4703,8 +4714,7 @@ TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) {
|
| TEST(HttpCache, WriteResponseInfo_Truncated) {
|
| MockHttpCache cache;
|
| disk_cache::Entry* entry;
|
| - ASSERT_TRUE(cache.CreateBackendEntry("http://www.google.com", &entry,
|
| - NULL));
|
| + ASSERT_TRUE(cache.CreateBackendEntry("http://www.google.com", &entry, NULL));
|
|
|
| std::string headers("HTTP/1.1 200 OK");
|
| headers = net::HttpUtil::AssembleRawHeaders(headers.data(), headers.size());
|
| @@ -4904,7 +4914,6 @@ TEST(HttpCache, SetTruncatedFlag) {
|
| c->trans.reset();
|
| MockHttpCache::SetTestMode(0);
|
|
|
| -
|
| // Make sure that we don't invoke the callback. We may have an issue if the
|
| // UrlRequestJob is killed directly (without cancelling the UrlRequest) so we
|
| // could end up with the transaction being deleted twice if we send any
|
| @@ -4967,19 +4976,21 @@ TEST(HttpCache, GET_IncompleteResource) {
|
| MockHttpCache cache;
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a regular request.
|
| std::string headers;
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| transaction.request_headers = EXTRA_HEADER;
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
|
|
|
| // We update the headers with the ones received while revalidating.
|
| @@ -5013,11 +5024,12 @@ TEST(HttpCache, GET_IncompleteResource_NoStore) {
|
| MockHttpCache cache;
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
| RemoveMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| @@ -5027,8 +5039,9 @@ TEST(HttpCache, GET_IncompleteResource_NoStore) {
|
| std::string response_headers(transaction.response_headers);
|
| response_headers += ("Cache-Control: no-store\n");
|
| transaction.response_headers = response_headers.c_str();
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| AddMockTransaction(&transaction);
|
|
|
| std::string headers;
|
| @@ -5059,11 +5072,12 @@ TEST(HttpCache, GET_IncompleteResource_Cancel) {
|
| MockHttpCache cache;
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
| RemoveMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| @@ -5073,8 +5087,9 @@ TEST(HttpCache, GET_IncompleteResource_Cancel) {
|
| std::string response_headers(transaction.response_headers);
|
| response_headers += ("Cache-Control: no-store\n");
|
| transaction.response_headers = response_headers.c_str();
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| AddMockTransaction(&transaction);
|
|
|
| MockHttpRequest request(transaction);
|
| @@ -5092,8 +5107,8 @@ TEST(HttpCache, GET_IncompleteResource_Cancel) {
|
|
|
| rv = c->trans->Start(&request, c->callback.callback(), net::BoundNetLog());
|
| EXPECT_EQ(net::ERR_IO_PENDING,
|
| - pending->trans->Start(&request, pending->callback.callback(),
|
| - net::BoundNetLog()));
|
| + pending->trans->Start(
|
| + &request, pending->callback.callback(), net::BoundNetLog()));
|
| EXPECT_EQ(net::OK, c->callback.GetResult(rv));
|
|
|
| // Make sure that the entry has some data stored.
|
| @@ -5119,11 +5134,12 @@ TEST(HttpCache, GET_IncompleteResource2) {
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| // Content-length will be intentionally bad.
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 50\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 50\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a regular request. We expect the code to fail the validation and
|
| @@ -5156,20 +5172,22 @@ TEST(HttpCache, GET_IncompleteResource3) {
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| // This should not require validation for 10 hours.
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2009 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Cache-Control: max-age= 36000\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2009 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Cache-Control: max-age= 36000\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a regular request.
|
| std::string headers;
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| transaction.request_headers = EXTRA_HEADER;
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
|
|
| scoped_ptr<Context> c(new Context);
|
| int rv = cache.CreateTransaction(&c->trans);
|
| @@ -5192,19 +5210,20 @@ TEST(HttpCache, GET_IncompleteResourceWithAuth) {
|
| MockHttpCache cache;
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a regular request.
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| - transaction.request_headers = "X-Require-Mock-Auth: dummy\r\n"
|
| - EXTRA_HEADER;
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + transaction.request_headers = "X-Require-Mock-Auth: dummy\r\n" EXTRA_HEADER;
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| RangeTransactionServer handler;
|
|
|
| scoped_ptr<Context> c(new Context);
|
| @@ -5218,8 +5237,8 @@ TEST(HttpCache, GET_IncompleteResourceWithAuth) {
|
| const net::HttpResponseInfo* response = c->trans->GetResponseInfo();
|
| ASSERT_TRUE(response);
|
| ASSERT_EQ(401, response->headers->response_code());
|
| - rv = c->trans->RestartWithAuth(net::AuthCredentials(),
|
| - c->callback.callback());
|
| + rv =
|
| + c->trans->RestartWithAuth(net::AuthCredentials(), c->callback.callback());
|
| EXPECT_EQ(net::OK, c->callback.GetResult(rv));
|
| response = c->trans->GetResponseInfo();
|
| ASSERT_TRUE(response);
|
| @@ -5242,11 +5261,12 @@ TEST(HttpCache, GET_IncompleteResource4) {
|
| MockHttpCache cache;
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2009 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2009 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a regular request.
|
| @@ -5281,11 +5301,12 @@ TEST(HttpCache, GET_CancelIncompleteResource) {
|
| MockHttpCache cache;
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2009 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2009 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a regular request.
|
| @@ -5333,17 +5354,18 @@ TEST(HttpCache, RangeGET_IncompleteResource) {
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| // Content-length will be intentionally bogus.
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: something\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 10\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: something\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 10\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a range request.
|
| std::string headers;
|
| - RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK,
|
| - &headers);
|
| + RunTransactionTestWithResponse(
|
| + cache.http_cache(), kRangeGET_TransactionOK, &headers);
|
|
|
| Verify206Response(headers, 40, 49);
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -5360,17 +5382,15 @@ TEST(HttpCache, SyncRead) {
|
| // any problems.
|
|
|
| ScopedMockTransaction transaction(kSimpleGET_Transaction);
|
| - transaction.test_mode |= (TEST_MODE_SYNC_CACHE_START |
|
| - TEST_MODE_SYNC_CACHE_READ |
|
| - TEST_MODE_SYNC_CACHE_WRITE);
|
| + transaction.test_mode |=
|
| + (TEST_MODE_SYNC_CACHE_START | TEST_MODE_SYNC_CACHE_READ |
|
| + TEST_MODE_SYNC_CACHE_WRITE);
|
|
|
| - MockHttpRequest r1(transaction),
|
| - r2(transaction),
|
| - r3(transaction);
|
| + MockHttpRequest r1(transaction), r2(transaction), r3(transaction);
|
|
|
| TestTransactionConsumer c1(net::DEFAULT_PRIORITY, cache.http_cache()),
|
| - c2(net::DEFAULT_PRIORITY, cache.http_cache()),
|
| - c3(net::DEFAULT_PRIORITY, cache.http_cache());
|
| + c2(net::DEFAULT_PRIORITY, cache.http_cache()),
|
| + c3(net::DEFAULT_PRIORITY, cache.http_cache());
|
|
|
| c1.Start(&r1, net::BoundNetLog());
|
|
|
| @@ -5687,25 +5707,24 @@ TEST(HttpCache, UpdatesRequestResponseTimeOn304) {
|
| const char* kUrl = "http://foobar";
|
| const char* kData = "body";
|
|
|
| - MockTransaction mock_network_response = { 0 };
|
| + MockTransaction mock_network_response = {0};
|
| mock_network_response.url = kUrl;
|
|
|
| AddMockTransaction(&mock_network_response);
|
|
|
| // Request |kUrl|, causing |kNetResponse1| to be written to the cache.
|
|
|
| - MockTransaction request = { 0 };
|
| + MockTransaction request = {0};
|
| request.url = kUrl;
|
| request.method = "GET";
|
| request.request_headers = "\r\n";
|
| request.data = kData;
|
|
|
| static const Response kNetResponse1 = {
|
| - "HTTP/1.1 200 OK",
|
| - "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - kData
|
| - };
|
| + "HTTP/1.1 200 OK",
|
| + "Date: Fri, 12 Jun 2009 21:46:42 GMT\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + kData};
|
|
|
| kNetResponse1.AssignTo(&mock_network_response);
|
|
|
| @@ -5717,10 +5736,7 @@ TEST(HttpCache, UpdatesRequestResponseTimeOn304) {
|
| request.load_flags = net::LOAD_VALIDATE_CACHE;
|
|
|
| static const Response kNetResponse2 = {
|
| - "HTTP/1.1 304 Not Modified",
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n",
|
| - ""
|
| - };
|
| + "HTTP/1.1 304 Not Modified", "Date: Wed, 22 Jul 2009 03:15:26 GMT\n", ""};
|
|
|
| kNetResponse2.AssignTo(&mock_network_response);
|
|
|
| @@ -5742,10 +5758,11 @@ TEST(HttpCache, UpdatesRequestResponseTimeOn304) {
|
| std::string headers;
|
| response.headers->GetNormalizedHeaders(&headers);
|
|
|
| - EXPECT_EQ("HTTP/1.1 200 OK\n"
|
| - "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| - "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| - headers);
|
| + EXPECT_EQ(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
|
| + "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
|
| + headers);
|
|
|
| RemoveMockTransaction(&mock_network_response);
|
| }
|
| @@ -5756,13 +5773,13 @@ TEST(HttpCache, WriteMetadata_OK) {
|
|
|
| // Write to the cache
|
| net::HttpResponseInfo response;
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction,
|
| - &response);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), kSimpleGET_Transaction, &response);
|
| EXPECT_TRUE(response.metadata.get() == NULL);
|
|
|
| // Trivial call.
|
| - cache.http_cache()->WriteMetadata(GURL("foo"), net::DEFAULT_PRIORITY,
|
| - Time::Now(), NULL, 0);
|
| + cache.http_cache()->WriteMetadata(
|
| + GURL("foo"), net::DEFAULT_PRIORITY, Time::Now(), NULL, 0);
|
|
|
| // Write meta data to the same entry.
|
| scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(50));
|
| @@ -5780,8 +5797,8 @@ TEST(HttpCache, WriteMetadata_OK) {
|
| // Makes sure we finish pending operations.
|
| base::MessageLoop::current()->RunUntilIdle();
|
|
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction,
|
| - &response);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), kSimpleGET_Transaction, &response);
|
| ASSERT_TRUE(response.metadata.get() != NULL);
|
| EXPECT_EQ(50, response.metadata->size());
|
| EXPECT_EQ(0, strcmp(response.metadata->data(), "Hi there"));
|
| @@ -5797,16 +5814,16 @@ TEST(HttpCache, WriteMetadata_Fail) {
|
|
|
| // Write to the cache
|
| net::HttpResponseInfo response;
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction,
|
| - &response);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), kSimpleGET_Transaction, &response);
|
| EXPECT_TRUE(response.metadata.get() == NULL);
|
|
|
| // Attempt to write meta data to the same entry.
|
| scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(50));
|
| memset(buf->data(), 0, buf->size());
|
| base::strlcpy(buf->data(), "Hi there", buf->size());
|
| - base::Time expected_time = response.response_time -
|
| - base::TimeDelta::FromMilliseconds(20);
|
| + base::Time expected_time =
|
| + response.response_time - base::TimeDelta::FromMilliseconds(20);
|
| cache.http_cache()->WriteMetadata(GURL(kSimpleGET_Transaction.url),
|
| net::DEFAULT_PRIORITY,
|
| expected_time,
|
| @@ -5816,8 +5833,8 @@ TEST(HttpCache, WriteMetadata_Fail) {
|
| // Makes sure we finish pending operations.
|
| base::MessageLoop::current()->RunUntilIdle();
|
|
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction,
|
| - &response);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), kSimpleGET_Transaction, &response);
|
| EXPECT_TRUE(response.metadata.get() == NULL);
|
|
|
| EXPECT_EQ(1, cache.network_layer()->transaction_count());
|
| @@ -5832,8 +5849,8 @@ TEST(HttpCache, ReadMetadata) {
|
|
|
| // Write to the cache
|
| net::HttpResponseInfo response;
|
| - RunTransactionTestWithResponseInfo(cache.http_cache(),
|
| - kTypicalGET_Transaction, &response);
|
| + RunTransactionTestWithResponseInfo(
|
| + cache.http_cache(), kTypicalGET_Transaction, &response);
|
| EXPECT_TRUE(response.metadata.get() == NULL);
|
|
|
| // Write meta data to the same entry.
|
| @@ -6079,9 +6096,10 @@ TEST(HttpCache, StopCachingSavesEntry) {
|
| // Force a response that can be resumed.
|
| MockTransaction mock_transaction(kSimpleGET_Transaction);
|
| AddMockTransaction(&mock_transaction);
|
| - mock_transaction.response_headers = "Cache-Control: max-age=10000\n"
|
| - "Content-Length: 42\n"
|
| - "Etag: \"foo\"\n";
|
| + mock_transaction.response_headers =
|
| + "Cache-Control: max-age=10000\n"
|
| + "Content-Length: 42\n"
|
| + "Etag: \"foo\"\n";
|
|
|
| int rv = trans->Start(&request, callback.callback(), net::BoundNetLog());
|
| EXPECT_EQ(net::OK, callback.GetResult(rv));
|
| @@ -6120,11 +6138,12 @@ TEST(HttpCache, StopCachingTruncatedEntry) {
|
| request.extra_headers.AddHeaderFromString(EXTRA_HEADER_LINE);
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| {
|
| @@ -6172,8 +6191,9 @@ TEST(HttpCache, TruncatedByContentLength) {
|
|
|
| MockTransaction transaction(kSimpleGET_Transaction);
|
| AddMockTransaction(&transaction);
|
| - transaction.response_headers = "Cache-Control: max-age=10000\n"
|
| - "Content-Length: 100\n";
|
| + transaction.response_headers =
|
| + "Cache-Control: max-age=10000\n"
|
| + "Content-Length: 100\n";
|
| RunTransactionTest(cache.http_cache(), transaction);
|
| RemoveMockTransaction(&transaction);
|
|
|
| @@ -6193,9 +6213,10 @@ TEST(HttpCache, TruncatedByContentLength2) {
|
|
|
| MockTransaction transaction(kSimpleGET_Transaction);
|
| AddMockTransaction(&transaction);
|
| - transaction.response_headers = "Cache-Control: max-age=10000\n"
|
| - "Content-Length: 100\n"
|
| - "Etag: \"foo\"\n";
|
| + transaction.response_headers =
|
| + "Cache-Control: max-age=10000\n"
|
| + "Content-Length: 100\n"
|
| + "Etag: \"foo\"\n";
|
| RunTransactionTest(cache.http_cache(), transaction);
|
| RemoveMockTransaction(&transaction);
|
|
|
| @@ -6234,8 +6255,7 @@ TEST(HttpCache, SetPriority) {
|
| if (cache.network_layer()->last_transaction()) {
|
| EXPECT_EQ(net::LOW,
|
| cache.network_layer()->last_create_transaction_priority());
|
| - EXPECT_EQ(net::LOW,
|
| - cache.network_layer()->last_transaction()->priority());
|
| + EXPECT_EQ(net::LOW, cache.network_layer()->last_transaction()->priority());
|
| }
|
|
|
| trans->SetPriority(net::HIGHEST);
|
| @@ -6268,12 +6288,14 @@ TEST(HttpCache, SetWebSocketHandshakeStreamCreateHelper) {
|
| trans->Start(&info, callback.callback(), net::BoundNetLog()));
|
|
|
| ASSERT_TRUE(cache.network_layer()->last_transaction());
|
| - EXPECT_FALSE(cache.network_layer()->last_transaction()->
|
| - websocket_handshake_stream_create_helper());
|
| + EXPECT_FALSE(cache.network_layer()
|
| + ->last_transaction()
|
| + ->websocket_handshake_stream_create_helper());
|
| trans->SetWebSocketHandshakeStreamCreateHelper(&create_helper);
|
| EXPECT_EQ(&create_helper,
|
| - cache.network_layer()->last_transaction()->
|
| - websocket_handshake_stream_create_helper());
|
| + cache.network_layer()
|
| + ->last_transaction()
|
| + ->websocket_handshake_stream_create_helper());
|
| EXPECT_EQ(net::OK, callback.WaitForResult());
|
| }
|
|
|
| @@ -6283,19 +6305,21 @@ TEST(HttpCache, SetPriorityNewTransaction) {
|
| MockHttpCache cache;
|
| AddMockTransaction(&kRangeGET_TransactionOK);
|
|
|
| - std::string raw_headers("HTTP/1.1 200 OK\n"
|
| - "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| - "ETag: \"foo\"\n"
|
| - "Accept-Ranges: bytes\n"
|
| - "Content-Length: 80\n");
|
| + std::string raw_headers(
|
| + "HTTP/1.1 200 OK\n"
|
| + "Last-Modified: Sat, 18 Apr 2007 01:10:43 GMT\n"
|
| + "ETag: \"foo\"\n"
|
| + "Accept-Ranges: bytes\n"
|
| + "Content-Length: 80\n");
|
| CreateTruncatedEntry(raw_headers, &cache);
|
|
|
| // Now make a regular request.
|
| std::string headers;
|
| MockTransaction transaction(kRangeGET_TransactionOK);
|
| transaction.request_headers = EXTRA_HEADER;
|
| - transaction.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| - "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
| + transaction.data =
|
| + "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
|
| + "rg: 50-59 rg: 60-69 rg: 70-79 ";
|
|
|
| scoped_ptr<net::HttpTransaction> trans;
|
| ASSERT_EQ(net::OK,
|
| @@ -6323,13 +6347,16 @@ TEST(HttpCache, SetPriorityNewTransaction) {
|
| RemoveMockTransaction(&kRangeGET_TransactionOK);
|
| }
|
|
|
| -int64 RunTransactionAndGetReceivedBytes(
|
| - MockHttpCache& cache,
|
| - const MockTransaction& trans_info) {
|
| +int64 RunTransactionAndGetReceivedBytes(MockHttpCache& cache,
|
| + const MockTransaction& trans_info) {
|
| int64 received_bytes = -1;
|
| - RunTransactionTestBase(cache.http_cache(), trans_info,
|
| - MockHttpRequest(trans_info), NULL, net::BoundNetLog(),
|
| - NULL, &received_bytes);
|
| + RunTransactionTestBase(cache.http_cache(),
|
| + trans_info,
|
| + MockHttpRequest(trans_info),
|
| + NULL,
|
| + net::BoundNetLog(),
|
| + NULL,
|
| + &received_bytes);
|
| return received_bytes;
|
| }
|
|
|
|
|