diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 17:52:37 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 17:52:37 +0000 |
commit | 6f40bf701483e182ddc9b2375d2a4cbfba0e47cf (patch) | |
tree | eecac7d0548493b01401ad032628f7579543da33 /net/http/http_cache_unittest.cc | |
parent | 00c8fcf95d515638a5779a082cff1f4b7fa33631 (diff) | |
download | chromium_src-6f40bf701483e182ddc9b2375d2a4cbfba0e47cf.zip chromium_src-6f40bf701483e182ddc9b2375d2a4cbfba0e47cf.tar.gz chromium_src-6f40bf701483e182ddc9b2375d2a4cbfba0e47cf.tar.bz2 |
Strip embedded "#" in URLs when constructing HTTP cache key.
BUG=http://crbug.com/17493
TEST=HttpCache.UrlContainingHash
Review URL: http://codereview.chromium.org/155972
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_unittest.cc')
-rw-r--r-- | net/http/http_cache_unittest.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 05c8920..2d67676 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -33,7 +33,7 @@ class MockDiskEntry : public disk_cache::Entry, : test_mode_(0), doomed_(false), sparse_(false) { } - MockDiskEntry(const std::string& key) + explicit MockDiskEntry(const std::string& key) : key_(key), doomed_(false), sparse_(false) { // // 'key' is prefixed with an identifier if it corresponds to a cached POST. @@ -1175,7 +1175,7 @@ TEST(HttpCache, DISABLED_ConditionalizedRequestUpdatesCache) { EXPECT_EQ(0, cache.disk_cache()->open_count()); EXPECT_EQ(1, cache.disk_cache()->create_count()); - // Request |kUrl| a second first time. Now |kNetResponse1| it is in the HTTP + // Request |kUrl| a second time. Now |kNetResponse1| it is in the HTTP // cache, so we don't hit the network. kUnexpectedResponse.AssignTo(&mock_network_response); // Network mock. @@ -1229,6 +1229,30 @@ TEST(HttpCache, DISABLED_ConditionalizedRequestUpdatesCache) { RemoveMockTransaction(&mock_network_response); } +TEST(HttpCache, UrlContainingHash) { + MockHttpCache cache; + + // Do a typical GET request -- should write an entry into our cache. + MockTransaction trans(kTypicalGET_Transaction); + RunTransactionTest(cache.http_cache(), trans); + + EXPECT_EQ(1, cache.network_layer()->transaction_count()); + EXPECT_EQ(0, cache.disk_cache()->open_count()); + EXPECT_EQ(1, cache.disk_cache()->create_count()); + + // Request the same URL, but this time with a reference section (hash). + // Since the cache key strips the hash sections, this should be a cache hit. + std::string url_with_hash = std::string(trans.url) + "#multiple#hashes"; + trans.url = url_with_hash.c_str(); + trans.load_flags = net::LOAD_ONLY_FROM_CACHE; + + RunTransactionTest(cache.http_cache(), trans); + + EXPECT_EQ(1, cache.network_layer()->transaction_count()); + EXPECT_EQ(1, cache.disk_cache()->open_count()); + EXPECT_EQ(1, cache.disk_cache()->create_count()); +} + TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Miss) { MockHttpCache cache; |