Chromium Code Reviews| Index: net/tools/quic/quic_in_memory_cache.cc |
| diff --git a/net/tools/quic/quic_in_memory_cache.cc b/net/tools/quic/quic_in_memory_cache.cc |
| index 5c02ca64dfb624d29da6f877c8c1e008c82adb6c..2d71b9eaa4ae71ce55aa702c6397cf79babef287 100644 |
| --- a/net/tools/quic/quic_in_memory_cache.cc |
| +++ b/net/tools/quic/quic_in_memory_cache.cc |
| @@ -86,16 +86,7 @@ QuicInMemoryCache* QuicInMemoryCache::GetInstance() { |
| const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse( |
| const BalsaHeaders& request_headers) const { |
| - string key = GetKey(request_headers); |
| - StringPiece url(key); |
| - // Removing the leading https:// or http://. |
| - if (StringPieceUtils::StartsWithIgnoreCase(url, "https://")) { |
| - url.remove_prefix(8); |
| - } else if (StringPieceUtils::StartsWithIgnoreCase(url, "http://")) { |
| - url.remove_prefix(7); |
| - } |
| - |
| - ResponseMap::const_iterator it = responses_.find(url.as_string()); |
| + ResponseMap::const_iterator it = responses_.find(GetKey(request_headers)); |
| if (it == responses_.end()) { |
| return NULL; |
| } |
| @@ -120,6 +111,10 @@ void QuicInMemoryCache::ResetForTests() { |
| } |
| QuicInMemoryCache::QuicInMemoryCache() { |
| + Initialize(); |
| +} |
| + |
| +void QuicInMemoryCache::Initialize() { |
| // If there's no defined cache dir, we have no initialization to do. |
| if (FLAGS_quic_in_memory_cache_dir.empty()) { |
| LOG(WARNING) << "No cache directory found. Skipping initialization."; |
| @@ -207,8 +202,15 @@ QuicInMemoryCache::~QuicInMemoryCache() { |
| } |
| string QuicInMemoryCache::GetKey(const BalsaHeaders& request_headers) const { |
| - return request_headers.GetHeader("host").as_string() + |
| - request_headers.request_uri().as_string(); |
| + StringPiece uri = request_headers.request_uri(); |
| + if (StringPieceUtils::StartsWithIgnoreCase(uri, "https://")) { |
| + uri.remove_prefix(8); |
| + return uri.as_string(); |
| + } else if (StringPieceUtils::StartsWithIgnoreCase(uri, "http://")) { |
| + uri.remove_prefix(7); |
| + return uri.as_string(); |
| + } |
| + return request_headers.GetHeader("host").as_string() + uri.as_string(); |
|
Ryan Hamilton
2013/07/04 14:46:03
So if the host header is set and the URI is fully
honghaiz
2013/07/04 17:34:04
Fixed.
On 2013/07/04 14:46:03, Ryan Hamilton wrot
|
| } |
| } // namespace tools |