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 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't | 5 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't |
6 // constantly adding and subtracting header sizes; this is ugly and error- | 6 // constantly adding and subtracting header sizes; this is ugly and error- |
7 // prone. | 7 // prone. |
8 | 8 |
9 #include "net/spdy/spdy_framer.h" | 9 #include "net/spdy/spdy_framer.h" |
10 | 10 |
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 SpdyGoAwayStatus status = GOAWAY_OK; | 1748 SpdyGoAwayStatus status = GOAWAY_OK; |
1749 if (protocol_version() >= SPDY3) { | 1749 if (protocol_version() >= SPDY3) { |
1750 uint32 status_raw = GOAWAY_OK; | 1750 uint32 status_raw = GOAWAY_OK; |
1751 successful_read = reader.ReadUInt32(&status_raw); | 1751 successful_read = reader.ReadUInt32(&status_raw); |
1752 DCHECK(successful_read); | 1752 DCHECK(successful_read); |
1753 if (SpdyConstants::IsValidGoAwayStatus(protocol_version(), | 1753 if (SpdyConstants::IsValidGoAwayStatus(protocol_version(), |
1754 status_raw)) { | 1754 status_raw)) { |
1755 status = SpdyConstants::ParseGoAwayStatus(protocol_version(), | 1755 status = SpdyConstants::ParseGoAwayStatus(protocol_version(), |
1756 status_raw); | 1756 status_raw); |
1757 } else { | 1757 } else { |
1758 // TODO(hkhalil): Probably best to OnError here, depending on | |
1759 // our interpretation of the spec. Keeping with existing liberal | |
1760 // behavior for now. | |
1761 DCHECK(false); | 1758 DCHECK(false); |
| 1759 // Throw an error for SPDY4+, keep liberal behavior |
| 1760 // for earlier versions. |
| 1761 if (protocol_version() > SPDY3) { |
| 1762 DLOG(WARNING) << "Invalid GO_AWAY status " << status_raw; |
| 1763 set_error(SPDY_INVALID_CONTROL_FRAME); |
| 1764 return 0; |
| 1765 } |
1762 } | 1766 } |
1763 } | 1767 } |
1764 // Finished parsing the GOAWAY header, call frame handler. | 1768 // Finished parsing the GOAWAY header, call frame handler. |
1765 visitor_->OnGoAway(current_frame_stream_id_, status); | 1769 visitor_->OnGoAway(current_frame_stream_id_, status); |
1766 } | 1770 } |
1767 } | 1771 } |
1768 | 1772 |
1769 // Handle remaining data as opaque. | 1773 // Handle remaining data as opaque. |
1770 bool processed_successfully = true; | 1774 bool processed_successfully = true; |
1771 if (len > 0) { | 1775 if (len > 0) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 } | 1817 } |
1814 | 1818 |
1815 SpdyRstStreamStatus status = RST_STREAM_INVALID; | 1819 SpdyRstStreamStatus status = RST_STREAM_INVALID; |
1816 uint32 status_raw = status; | 1820 uint32 status_raw = status; |
1817 bool successful_read = reader.ReadUInt32(&status_raw); | 1821 bool successful_read = reader.ReadUInt32(&status_raw); |
1818 DCHECK(successful_read); | 1822 DCHECK(successful_read); |
1819 if (SpdyConstants::IsValidRstStreamStatus(protocol_version(), | 1823 if (SpdyConstants::IsValidRstStreamStatus(protocol_version(), |
1820 status_raw)) { | 1824 status_raw)) { |
1821 status = static_cast<SpdyRstStreamStatus>(status_raw); | 1825 status = static_cast<SpdyRstStreamStatus>(status_raw); |
1822 } else { | 1826 } else { |
1823 // TODO(hkhalil): Probably best to OnError here, depending on | 1827 // Throw an error for SPDY4+, keep liberal behavior |
1824 // our interpretation of the spec. Keeping with existing liberal | 1828 // for earlier versions. |
1825 // behavior for now. | 1829 if (protocol_version() > SPDY3) { |
| 1830 DLOG(WARNING) << "Invalid RST_STREAM status " << status_raw; |
| 1831 set_error(SPDY_INVALID_CONTROL_FRAME); |
| 1832 return 0; |
| 1833 } |
1826 } | 1834 } |
1827 // Finished parsing the RST_STREAM header, call frame handler. | 1835 // Finished parsing the RST_STREAM header, call frame handler. |
1828 visitor_->OnRstStream(current_frame_stream_id_, status); | 1836 visitor_->OnRstStream(current_frame_stream_id_, status); |
1829 } | 1837 } |
1830 } | 1838 } |
1831 | 1839 |
1832 // Handle remaining data as opaque. | 1840 // Handle remaining data as opaque. |
1833 bool processed_successfully = true; | 1841 bool processed_successfully = true; |
1834 if (len > 0) { | 1842 if (len > 0) { |
1835 processed_successfully = visitor_->OnRstStreamFrameData(data, len); | 1843 processed_successfully = visitor_->OnRstStreamFrameData(data, len); |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2959 builder->Seek(compressed_size); | 2967 builder->Seek(compressed_size); |
2960 builder->RewriteLength(*this); | 2968 builder->RewriteLength(*this); |
2961 | 2969 |
2962 pre_compress_bytes.Add(uncompressed_len); | 2970 pre_compress_bytes.Add(uncompressed_len); |
2963 post_compress_bytes.Add(compressed_size); | 2971 post_compress_bytes.Add(compressed_size); |
2964 | 2972 |
2965 compressed_frames.Increment(); | 2973 compressed_frames.Increment(); |
2966 } | 2974 } |
2967 | 2975 |
2968 } // namespace net | 2976 } // namespace net |
OLD | NEW |