Index: net/spdy/spdy_session.cc |
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
index fab1e0f2bd290fd25158a994841e65467248e763..242e41459e3425469ceddcd30e02f447e20c6ae9 100644 |
--- a/net/spdy/spdy_session.cc |
+++ b/net/spdy/spdy_session.cc |
@@ -264,6 +264,36 @@ class RequestEquals { |
const base::WeakPtr<SpdyStreamRequest> request_; |
}; |
+// Splits headers received in SYN_STREAM into request and response headers. |
+void GetPushPromiseHeadersFromSynStream(SpdyHeaderBlock* response_headers, |
+ SpdyHeaderBlock* request_headers, |
+ SpdyMajorVersion protocol_version) { |
+ DCHECK(response_headers); |
+ DCHECK(request_headers); |
+ |
+ // SPDY 2 server push urls are specified in a single "url" header. |
+ if (protocol_version == SPDY2) { |
+ SpdyHeaderBlock::iterator it; |
+ it = response_headers->find("url"); |
+ if (it != response_headers->end()) { |
+ (*request_headers)["url"] = it->second; |
+ response_headers->erase(it); |
+ } |
+ return; |
+ } |
+ |
+ DCHECK_LT(SPDY2, protocol_version); |
+ static const char* kRequestHeaders[] = { ":scheme", ":host", ":path" }; |
Johnny
2014/06/05 02:56:04
Also :authority (instead of :host) for HTTP/2.
ni
baranovich
2014/06/05 19:16:58
Done.
|
+ SpdyHeaderBlock::iterator it; |
+ for (size_t i = 0; i < arraysize(kRequestHeaders); ++i) { |
+ it = response_headers->find(kRequestHeaders[i]); |
+ if (it != response_headers->end()) { |
+ (*request_headers)[kRequestHeaders[i]] = it->second; |
+ response_headers->erase(it); |
+ } |
+ } |
Johnny
2014/06/05 02:56:04
Can we add unit testing on this in SpdySessionTest
baranovich
2014/06/05 19:16:58
Done.
|
+} |
+ |
// The maximum number of concurrent streams we will ever create. Even if |
// the server permits more, we will never exceed this limit. |
const size_t kMaxConcurrentStreamLimit = 256; |
@@ -2126,8 +2156,20 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
} |
// Parse the headers. |
+ |
+ // Split headers to simulate push promise and response. |
+ SpdyHeaderBlock request_headers; |
+ SpdyHeaderBlock response_headers(headers); |
+ GetPushPromiseHeadersFromSynStream(&response_headers, |
Johnny
2014/06/05 02:56:04
Since we're copying here anyway, how about passing
baranovich
2014/06/05 19:16:57
Done.
That's the best name I've come up to;) maybe
|
+ &request_headers, |
+ GetProtocolVersion()); |
+ |
+ if (active_it->second.stream-> |
+ OnPushPromiseHeadersReceived(request_headers) != OK) |
+ return; |
+ |
if (OnInitialResponseHeadersReceived( |
- headers, response_time, |
+ response_headers, response_time, |
recv_first_byte_time, active_it->second.stream) != OK) |
return; |