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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 size_t data_len) { | 1013 size_t data_len) { |
1014 DCHECK_EQ(SPDY_CONTROL_FRAME_HEADER_BLOCK, state_); | 1014 DCHECK_EQ(SPDY_CONTROL_FRAME_HEADER_BLOCK, state_); |
1015 const SpdyControlFrame control_frame(current_frame_buffer_.get(), false); | 1015 const SpdyControlFrame control_frame(current_frame_buffer_.get(), false); |
1016 | 1016 |
1017 bool processed_successfully = true; | 1017 bool processed_successfully = true; |
1018 SpdyStreamId stream_id = kInvalidStream; | 1018 SpdyStreamId stream_id = kInvalidStream; |
1019 if (control_frame.type() == SYN_STREAM) { | 1019 if (control_frame.type() == SYN_STREAM) { |
1020 stream_id = reinterpret_cast<const SpdySynStreamControlFrame*>( | 1020 stream_id = reinterpret_cast<const SpdySynStreamControlFrame*>( |
1021 &control_frame)->stream_id(); | 1021 &control_frame)->stream_id(); |
1022 } else if (control_frame.type() == SYN_REPLY) { | 1022 } else if (control_frame.type() == SYN_REPLY) { |
1023 stream_id = reinterpret_cast<const SpdySynReplyControlFrame*>( | 1023 SpdyFrameReader reader(current_frame_buffer_.get(), current_frame_len_); |
1024 &control_frame)->stream_id(); | 1024 reader.Seek(SpdyFrame::kHeaderSize); // Seek past frame header. |
| 1025 bool read_successful = reader.ReadUInt31(&stream_id); |
| 1026 DCHECK(read_successful); |
1025 } else if (control_frame.type() == HEADERS) { | 1027 } else if (control_frame.type() == HEADERS) { |
1026 stream_id = reinterpret_cast<const SpdyHeadersControlFrame*>( | 1028 stream_id = reinterpret_cast<const SpdyHeadersControlFrame*>( |
1027 &control_frame)->stream_id(); | 1029 &control_frame)->stream_id(); |
1028 } else { | 1030 } else { |
1029 LOG(DFATAL) << "Unhandled frame type in ProcessControlFrameHeaderBlock."; | 1031 LOG(DFATAL) << "Unhandled frame type in ProcessControlFrameHeaderBlock."; |
1030 } | 1032 } |
1031 size_t process_bytes = std::min(data_len, remaining_control_payload_); | 1033 size_t process_bytes = std::min(data_len, remaining_control_payload_); |
1032 if (process_bytes > 0) { | 1034 if (process_bytes > 0) { |
1033 if (enable_compression_) { | 1035 if (enable_compression_) { |
1034 processed_successfully = IncrementallyDecompressControlFrameHeaderData( | 1036 processed_successfully = IncrementallyDecompressControlFrameHeaderData( |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 { | 1803 { |
1802 const SpdySynStreamControlFrame& syn_frame = | 1804 const SpdySynStreamControlFrame& syn_frame = |
1803 reinterpret_cast<const SpdySynStreamControlFrame&>(frame); | 1805 reinterpret_cast<const SpdySynStreamControlFrame&>(frame); |
1804 frame_size = SpdySynStreamControlFrame::size(); | 1806 frame_size = SpdySynStreamControlFrame::size(); |
1805 *payload_length = syn_frame.header_block_len(); | 1807 *payload_length = syn_frame.header_block_len(); |
1806 *header_length = frame_size; | 1808 *header_length = frame_size; |
1807 *payload = frame.data() + *header_length; | 1809 *payload = frame.data() + *header_length; |
1808 } | 1810 } |
1809 break; | 1811 break; |
1810 case SYN_REPLY: | 1812 case SYN_REPLY: |
1811 { | 1813 *header_length = GetSynReplyMinimumSize(); |
1812 *header_length = GetSynReplyMinimumSize(); | 1814 *payload_length = frame.length() - |
1813 *payload_length = frame.length() - | 1815 (*header_length - GetControlFrameMinimumSize()); |
1814 (*header_length - GetControlFrameMinimumSize()); | 1816 *payload = frame.data() + *header_length; |
1815 *payload = frame.data() + *header_length; | |
1816 } | |
1817 break; | 1817 break; |
1818 case HEADERS: | 1818 case HEADERS: |
1819 { | 1819 { |
1820 const SpdyHeadersControlFrame& headers_frame = | 1820 const SpdyHeadersControlFrame& headers_frame = |
1821 reinterpret_cast<const SpdyHeadersControlFrame&>(frame); | 1821 reinterpret_cast<const SpdyHeadersControlFrame&>(frame); |
1822 frame_size = SpdyHeadersControlFrame::size(); | 1822 frame_size = SpdyHeadersControlFrame::size(); |
1823 *payload_length = headers_frame.header_block_len(); | 1823 *payload_length = headers_frame.header_block_len(); |
1824 *header_length = frame_size; | 1824 *header_length = frame_size; |
1825 *payload = frame.data() + *header_length; | 1825 *payload = frame.data() + *header_length; |
1826 // SPDY 2 had two bytes of unused space preceeding payload. | 1826 // SPDY 2 had two bytes of unused space preceeding payload. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 builder->WriteString(it->first); | 2060 builder->WriteString(it->first); |
2061 builder->WriteString(it->second); | 2061 builder->WriteString(it->second); |
2062 } else { | 2062 } else { |
2063 builder->WriteStringPiece32(it->first); | 2063 builder->WriteStringPiece32(it->first); |
2064 builder->WriteStringPiece32(it->second); | 2064 builder->WriteStringPiece32(it->second); |
2065 } | 2065 } |
2066 } | 2066 } |
2067 } | 2067 } |
2068 | 2068 |
2069 } // namespace net | 2069 } // namespace net |
OLD | NEW |