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 1f31b9cfe1362dc6a14a4e673ea4fbf68d90e6ec..f3fc367efe717b821b9cc78357284d46e8b82dba 100644 |
--- a/net/tools/quic/quic_in_memory_cache.cc |
+++ b/net/tools/quic/quic_in_memory_cache.cc |
@@ -72,6 +72,18 @@ void QuicInMemoryCache::AddSimpleResponse(StringPiece host, |
AddResponse(host, path, response_headers, body); |
} |
+void QuicInMemoryCache::AddBidirectionalResponse( |
+ StringPiece host, |
+ StringPiece path, |
+ int response_code, |
+ const std::vector<std::string>& body_chunks, |
+ const SpdyHeaderBlock& response_trailers) { |
+ SpdyHeaderBlock response_headers; |
+ response_headers[":status"] = IntToString(response_code); |
+ AddResponseImpl(host, path, BIDIRECTIONAL, response_headers, "", body_chunks, |
+ response_trailers); |
+} |
+ |
void QuicInMemoryCache::AddSimpleResponseWithServerPushResources( |
StringPiece host, |
StringPiece path, |
@@ -207,6 +219,18 @@ void QuicInMemoryCache::AddResponseImpl( |
const SpdyHeaderBlock& response_headers, |
StringPiece response_body, |
const SpdyHeaderBlock& response_trailers) { |
+ std::vector<std::string> body_chunks; |
+ AddResponseImpl(host, path, response_type, response_headers, response_body, |
+ body_chunks, response_trailers); |
+} |
+void QuicInMemoryCache::AddResponseImpl( |
+ StringPiece host, |
+ StringPiece path, |
+ SpecialResponseType response_type, |
+ const SpdyHeaderBlock& response_headers, |
+ StringPiece response_body, |
+ const std::vector<std::string>& body_chunks, |
+ const SpdyHeaderBlock& response_trailers) { |
DCHECK(!host.empty()) << "Host must be populated, e.g. \"www.google.com\""; |
string key = GetKey(host, path); |
if (ContainsKey(responses_, key)) { |
@@ -216,7 +240,12 @@ void QuicInMemoryCache::AddResponseImpl( |
Response* new_response = new Response(); |
new_response->set_response_type(response_type); |
new_response->set_headers(response_headers); |
- new_response->set_body(response_body); |
+ if (response_type != BIDIRECTIONAL) { |
+ CHECK(body_chunks.empty()); |
+ new_response->set_body(response_body); |
+ } else { |
+ new_response->SetBodyChunks(body_chunks); |
+ } |
new_response->set_trailers(response_trailers); |
responses_[key] = new_response; |
} |