OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ | 5 #ifndef NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ |
6 #define NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ | 6 #define NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 NEED_MORE_DATA, | 71 NEED_MORE_DATA, |
72 // Set when a complete block has been read, but unprocessed data remains. | 72 // Set when a complete block has been read, but unprocessed data remains. |
73 TOO_MUCH_DATA, | 73 TOO_MUCH_DATA, |
74 // Set when a block exceeds |MaxNumberOfHeadersForVersion| headers. | 74 // Set when a block exceeds |MaxNumberOfHeadersForVersion| headers. |
75 HEADER_BLOCK_TOO_LARGE, | 75 HEADER_BLOCK_TOO_LARGE, |
76 // Set when a header key or value exceeds |kMaximumFieldLength|. | 76 // Set when a header key or value exceeds |kMaximumFieldLength|. |
77 HEADER_FIELD_TOO_LARGE, | 77 HEADER_FIELD_TOO_LARGE, |
78 }; | 78 }; |
79 ParserError get_error() const { return error_; } | 79 ParserError get_error() const { return error_; } |
80 | 80 |
81 // Resets the state of the parser to prepare it for a headers block of a | |
82 // new frame. | |
83 void Reset(); | |
84 | |
85 // Returns the size in bytes of a length field in a SPDY header. | 81 // Returns the size in bytes of a length field in a SPDY header. |
86 static size_t LengthFieldSizeForVersion(SpdyMajorVersion spdy_version); | 82 static size_t LengthFieldSizeForVersion(SpdyMajorVersion spdy_version); |
87 | 83 |
88 // Returns the maximal number of headers in a SPDY headers block. | 84 // Returns the maximal number of headers in a SPDY headers block. |
89 static size_t MaxNumberOfHeadersForVersion(SpdyMajorVersion spdy_version); | 85 static size_t MaxNumberOfHeadersForVersion(SpdyMajorVersion spdy_version); |
90 | 86 |
91 private: | 87 private: |
92 typedef SpdyPrefixedBufferReader Reader; | 88 typedef SpdyPrefixedBufferReader Reader; |
93 | 89 |
94 // Parses and sanity-checks header block length. | 90 // Parses and sanity-checks header block length. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 136 |
141 // The current header block stream identifier. | 137 // The current header block stream identifier. |
142 SpdyStreamId stream_id_; | 138 SpdyStreamId stream_id_; |
143 | 139 |
144 ParserError error_; | 140 ParserError error_; |
145 }; | 141 }; |
146 | 142 |
147 } // namespace net | 143 } // namespace net |
148 | 144 |
149 #endif // NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ | 145 #endif // NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ |
OLD | NEW |