| 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/chromium/spdy_session.h" | 5 #include "net/spdy/chromium/spdy_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 UnclaimedPushedStreamContainer::const_iterator pushed_it = | 1658 UnclaimedPushedStreamContainer::const_iterator pushed_it = |
| 1659 unclaimed_pushed_streams_.lower_bound(gurl); | 1659 unclaimed_pushed_streams_.lower_bound(gurl); |
| 1660 if (pushed_it != unclaimed_pushed_streams_.end() && | 1660 if (pushed_it != unclaimed_pushed_streams_.end() && |
| 1661 pushed_it->first == gurl) { | 1661 pushed_it->first == gurl) { |
| 1662 EnqueueResetStreamFrame( | 1662 EnqueueResetStreamFrame( |
| 1663 stream_id, request_priority, ERROR_CODE_REFUSED_STREAM, | 1663 stream_id, request_priority, ERROR_CODE_REFUSED_STREAM, |
| 1664 "Received duplicate pushed stream with url: " + gurl.spec()); | 1664 "Received duplicate pushed stream with url: " + gurl.spec()); |
| 1665 return; | 1665 return; |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 // "Promised requests MUST be cacheable and MUST be safe [...]" (RFC7540 |
| 1669 // Section 8.2). Only cacheable safe request methods are GET and HEAD. |
| 1670 SpdyHeaderBlock::const_iterator it = headers.find(":method"); |
| 1671 if (it == headers.end() || |
| 1672 (it->second.compare("GET") != 0 && it->second.compare("HEAD") != 0)) { |
| 1673 EnqueueResetStreamFrame( |
| 1674 stream_id, request_priority, ERROR_CODE_REFUSED_STREAM, |
| 1675 SpdyStringPrintf( |
| 1676 "Rejected push stream %d due to inadequate request method", |
| 1677 associated_stream_id)); |
| 1678 return; |
| 1679 } |
| 1680 |
| 1668 auto stream = base::MakeUnique<SpdyStream>( | 1681 auto stream = base::MakeUnique<SpdyStream>( |
| 1669 SPDY_PUSH_STREAM, GetWeakPtr(), gurl, request_priority, | 1682 SPDY_PUSH_STREAM, GetWeakPtr(), gurl, request_priority, |
| 1670 stream_initial_send_window_size_, stream_max_recv_window_size_, net_log_); | 1683 stream_initial_send_window_size_, stream_max_recv_window_size_, net_log_); |
| 1671 stream->set_stream_id(stream_id); | 1684 stream->set_stream_id(stream_id); |
| 1672 | 1685 |
| 1673 // Convert RequestPriority to a SpdyPriority to send in a PRIORITY frame. | 1686 // Convert RequestPriority to a SpdyPriority to send in a PRIORITY frame. |
| 1674 SpdyPriority spdy_priority = | 1687 SpdyPriority spdy_priority = |
| 1675 ConvertRequestPriorityToSpdyPriority(request_priority); | 1688 ConvertRequestPriorityToSpdyPriority(request_priority); |
| 1676 SpdyStreamId dependency_id = 0; | 1689 SpdyStreamId dependency_id = 0; |
| 1677 bool exclusive = false; | 1690 bool exclusive = false; |
| (...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 if (!queue->empty()) { | 3230 if (!queue->empty()) { |
| 3218 SpdyStreamId stream_id = queue->front(); | 3231 SpdyStreamId stream_id = queue->front(); |
| 3219 queue->pop_front(); | 3232 queue->pop_front(); |
| 3220 return stream_id; | 3233 return stream_id; |
| 3221 } | 3234 } |
| 3222 } | 3235 } |
| 3223 return 0; | 3236 return 0; |
| 3224 } | 3237 } |
| 3225 | 3238 |
| 3226 } // namespace net | 3239 } // namespace net |
| OLD | NEW |