| 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 6ed7dd5f8320fca1f0e7b0f368a5a4def7d50d4c..8e97f553ac08b313adfc68f93eec89a42234edf0 100644
|
| --- a/net/tools/quic/quic_in_memory_cache.cc
|
| +++ b/net/tools/quic/quic_in_memory_cache.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/file_util.h"
|
| #include "base/files/file_enumerator.h"
|
| #include "base/stl_util.h"
|
| +#include "base/strings/string_number_conversions.h"
|
|
|
| using base::FilePath;
|
| using base::StringPiece;
|
| @@ -93,6 +94,36 @@ const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse(
|
| return it->second;
|
| }
|
|
|
| +void QuicInMemoryCache::AddOrVerifyResponse(StringPiece method,
|
| + StringPiece path,
|
| + StringPiece version,
|
| + StringPiece response_code,
|
| + StringPiece response_detail,
|
| + StringPiece body) {
|
| + BalsaHeaders request_headers, response_headers;
|
| + request_headers.SetRequestFirstlineFromStringPieces(method,
|
| + path,
|
| + version);
|
| + response_headers.SetRequestFirstlineFromStringPieces(version,
|
| + response_code,
|
| + response_detail);
|
| + response_headers.AppendHeader("content-length",
|
| + base::IntToString(body.length()));
|
| +
|
| + // Check if response already exists and matches.
|
| + const QuicInMemoryCache::Response* cached_response =
|
| + GetResponse(request_headers);
|
| + if (cached_response == NULL) {
|
| + AddResponse(request_headers, response_headers, body);
|
| + return;
|
| + }
|
| + string cached_response_headers_str, response_headers_str;
|
| + cached_response->headers().DumpToString(&cached_response_headers_str);
|
| + response_headers.DumpToString(&response_headers_str);
|
| + CHECK_EQ(cached_response_headers_str, response_headers_str);
|
| + CHECK_EQ(cached_response->body(), body);
|
| +}
|
| +
|
| void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers,
|
| const BalsaHeaders& response_headers,
|
| StringPiece response_body) {
|
|
|