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_HPACK_DECODER_H_ | 5 #ifndef NET_SPDY_HPACK_DECODER_H_ |
6 #define NET_SPDY_HPACK_DECODER_H_ | 6 #define NET_SPDY_HPACK_DECODER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 private: | 70 private: |
71 // Adds the header representation to |decoded_block_|, applying the | 71 // Adds the header representation to |decoded_block_|, applying the |
72 // following rules, as per sections 8.1.3.3 & 8.1.3.4 of the HTTP2 draft | 72 // following rules, as per sections 8.1.3.3 & 8.1.3.4 of the HTTP2 draft |
73 // specification: | 73 // specification: |
74 // - Multiple values of the Cookie header are joined, delmited by '; '. | 74 // - Multiple values of the Cookie header are joined, delmited by '; '. |
75 // This reconstruction is required to properly handle Cookie crumbling. | 75 // This reconstruction is required to properly handle Cookie crumbling. |
76 // - Multiple values of other headers are joined and delimited by '\0'. | 76 // - Multiple values of other headers are joined and delimited by '\0'. |
77 // Note that this may be too accomodating, as the sender's HTTP2 layer | 77 // Note that this may be too accomodating, as the sender's HTTP2 layer |
78 // should have already joined and delimited these values. | 78 // should have already joined and delimited these values. |
79 // | 79 // |
| 80 // Returns false if a pseudo-header field follows a regular header one, which |
| 81 // MUST be treated as malformed, as per sections 8.1.2.1. of the HTTP2 draft |
| 82 // specification. |
| 83 // |
80 // TODO(jgraettinger): This method will eventually emit to the | 84 // TODO(jgraettinger): This method will eventually emit to the |
81 // SpdyHeadersHandlerInterface visitor. | 85 // SpdyHeadersHandlerInterface visitor. |
82 void HandleHeaderRepresentation(base::StringPiece name, | 86 bool HandleHeaderRepresentation(base::StringPiece name, |
83 base::StringPiece value); | 87 base::StringPiece value); |
84 | 88 |
85 const uint32 max_string_literal_size_; | 89 const uint32 max_string_literal_size_; |
86 HpackHeaderTable header_table_; | 90 HpackHeaderTable header_table_; |
87 | 91 |
88 // Incrementally reconstructed cookie value. | 92 // Incrementally reconstructed cookie value. |
89 std::string cookie_value_; | 93 std::string cookie_value_; |
90 | 94 |
91 // TODO(jgraettinger): Buffer for headers data, and storage for the last- | 95 // TODO(jgraettinger): Buffer for headers data, and storage for the last- |
92 // processed headers block. Both will be removed with the switch to | 96 // processed headers block. Both will be removed with the switch to |
93 // SpdyHeadersHandlerInterface. | 97 // SpdyHeadersHandlerInterface. |
94 std::string headers_block_buffer_; | 98 std::string headers_block_buffer_; |
95 std::map<std::string, std::string> decoded_block_; | 99 std::map<std::string, std::string> decoded_block_; |
96 | 100 |
| 101 // Flag to keep track of having seen a regular header field. |
| 102 bool regular_header_seen_; |
| 103 |
97 // Huffman table to be applied to decoded Huffman literals, | 104 // Huffman table to be applied to decoded Huffman literals, |
98 // and scratch space for storing those decoded literals. | 105 // and scratch space for storing those decoded literals. |
99 const HpackHuffmanTable& huffman_table_; | 106 const HpackHuffmanTable& huffman_table_; |
100 std::string key_buffer_, value_buffer_; | 107 std::string key_buffer_, value_buffer_; |
101 | 108 |
102 // Handlers for decoding HPACK opcodes and header representations | 109 // Handlers for decoding HPACK opcodes and header representations |
103 // (or parts thereof). These methods return true on success and | 110 // (or parts thereof). These methods return true on success and |
104 // false on error. | 111 // false on error. |
105 bool DecodeNextOpcode(HpackInputStream* input_stream); | 112 bool DecodeNextOpcode(HpackInputStream* input_stream); |
106 bool DecodeNextHeaderTableSizeUpdate(HpackInputStream* input_stream); | 113 bool DecodeNextHeaderTableSizeUpdate(HpackInputStream* input_stream); |
107 bool DecodeNextIndexedHeader(HpackInputStream* input_stream); | 114 bool DecodeNextIndexedHeader(HpackInputStream* input_stream); |
108 bool DecodeNextLiteralHeader(HpackInputStream* input_stream, | 115 bool DecodeNextLiteralHeader(HpackInputStream* input_stream, |
109 bool should_index); | 116 bool should_index); |
110 bool DecodeNextName(HpackInputStream* input_stream, | 117 bool DecodeNextName(HpackInputStream* input_stream, |
111 base::StringPiece* next_name); | 118 base::StringPiece* next_name); |
112 bool DecodeNextStringLiteral(HpackInputStream* input_stream, | 119 bool DecodeNextStringLiteral(HpackInputStream* input_stream, |
113 bool is_header_key, // As distinct from a value. | 120 bool is_header_key, // As distinct from a value. |
114 base::StringPiece* output); | 121 base::StringPiece* output); |
115 | 122 |
116 DISALLOW_COPY_AND_ASSIGN(HpackDecoder); | 123 DISALLOW_COPY_AND_ASSIGN(HpackDecoder); |
117 }; | 124 }; |
118 | 125 |
119 } // namespace net | 126 } // namespace net |
120 | 127 |
121 #endif // NET_SPDY_HPACK_DECODER_H_ | 128 #endif // NET_SPDY_HPACK_DECODER_H_ |
OLD | NEW |