| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return GOAWAY_FRAME_SIZE_ERROR; | 380 return GOAWAY_FRAME_SIZE_ERROR; |
| 381 case ERR_SPDY_COMPRESSION_ERROR: | 381 case ERR_SPDY_COMPRESSION_ERROR: |
| 382 return GOAWAY_COMPRESSION_ERROR; | 382 return GOAWAY_COMPRESSION_ERROR; |
| 383 case ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY: | 383 case ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY: |
| 384 return GOAWAY_INADEQUATE_SECURITY; | 384 return GOAWAY_INADEQUATE_SECURITY; |
| 385 default: | 385 default: |
| 386 return GOAWAY_PROTOCOL_ERROR; | 386 return GOAWAY_PROTOCOL_ERROR; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 void SplitPushedHeadersToRequestAndResponse(const SpdyHeaderBlock& headers, |
| 391 SpdyMajorVersion protocol_version, |
| 392 SpdyHeaderBlock* request_headers, |
| 393 SpdyHeaderBlock* response_headers) { |
| 394 DCHECK(response_headers); |
| 395 DCHECK(request_headers); |
| 396 for (SpdyHeaderBlock::const_iterator it = headers.begin(); |
| 397 it != headers.end(); |
| 398 ++it) { |
| 399 SpdyHeaderBlock* to_insert = response_headers; |
| 400 if (protocol_version == SPDY2) { |
| 401 if (it->first == "url") |
| 402 to_insert = request_headers; |
| 403 } else { |
| 404 const char* host = protocol_version >= SPDY4 ? ":authority" : ":host"; |
| 405 static const char* scheme = ":scheme"; |
| 406 static const char* path = ":path"; |
| 407 if (it->first == host || it->first == scheme || it->first == path) |
| 408 to_insert = request_headers; |
| 409 } |
| 410 to_insert->insert(*it); |
| 411 } |
| 412 } |
| 413 |
| 390 SpdyStreamRequest::SpdyStreamRequest() : weak_ptr_factory_(this) { | 414 SpdyStreamRequest::SpdyStreamRequest() : weak_ptr_factory_(this) { |
| 391 Reset(); | 415 Reset(); |
| 392 } | 416 } |
| 393 | 417 |
| 394 SpdyStreamRequest::~SpdyStreamRequest() { | 418 SpdyStreamRequest::~SpdyStreamRequest() { |
| 395 CancelRequest(); | 419 CancelRequest(); |
| 396 } | 420 } |
| 397 | 421 |
| 398 int SpdyStreamRequest::StartRequest( | 422 int SpdyStreamRequest::StartRequest( |
| 399 SpdyStreamType type, | 423 SpdyStreamType type, |
| (...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 | 2206 |
| 2183 InsertActivatedStream(stream.Pass()); | 2207 InsertActivatedStream(stream.Pass()); |
| 2184 | 2208 |
| 2185 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); | 2209 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); |
| 2186 if (active_it == active_streams_.end()) { | 2210 if (active_it == active_streams_.end()) { |
| 2187 NOTREACHED(); | 2211 NOTREACHED(); |
| 2188 return; | 2212 return; |
| 2189 } | 2213 } |
| 2190 | 2214 |
| 2191 // Parse the headers. | 2215 // Parse the headers. |
| 2192 if (OnInitialResponseHeadersReceived( | 2216 |
| 2193 headers, response_time, | 2217 // Split headers to simulate push promise and response. |
| 2194 recv_first_byte_time, active_it->second.stream) != OK) | 2218 SpdyHeaderBlock request_headers; |
| 2219 SpdyHeaderBlock response_headers; |
| 2220 SplitPushedHeadersToRequestAndResponse( |
| 2221 headers, GetProtocolVersion(), &request_headers, &response_headers); |
| 2222 |
| 2223 if (active_it->second.stream->OnPushPromiseHeadersReceived(request_headers) != |
| 2224 OK) |
| 2225 return; |
| 2226 |
| 2227 if (OnInitialResponseHeadersReceived(response_headers, |
| 2228 response_time, |
| 2229 recv_first_byte_time, |
| 2230 active_it->second.stream) != OK) |
| 2195 return; | 2231 return; |
| 2196 | 2232 |
| 2197 base::StatsCounter push_requests("spdy.pushed_streams"); | 2233 base::StatsCounter push_requests("spdy.pushed_streams"); |
| 2198 push_requests.Increment(); | 2234 push_requests.Increment(); |
| 2199 } | 2235 } |
| 2200 | 2236 |
| 2201 void SpdySession::DeleteExpiredPushedStreams() { | 2237 void SpdySession::DeleteExpiredPushedStreams() { |
| 2202 if (unclaimed_pushed_streams_.empty()) | 2238 if (unclaimed_pushed_streams_.empty()) |
| 2203 return; | 2239 return; |
| 2204 | 2240 |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3009 if (!queue->empty()) { | 3045 if (!queue->empty()) { |
| 3010 SpdyStreamId stream_id = queue->front(); | 3046 SpdyStreamId stream_id = queue->front(); |
| 3011 queue->pop_front(); | 3047 queue->pop_front(); |
| 3012 return stream_id; | 3048 return stream_id; |
| 3013 } | 3049 } |
| 3014 } | 3050 } |
| 3015 return 0; | 3051 return 0; |
| 3016 } | 3052 } |
| 3017 | 3053 |
| 3018 } // namespace net | 3054 } // namespace net |
| OLD | NEW |