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 #include "net/spdy/hpack/hpack_decoder.h" | 5 #include "net/spdy/hpack/hpack_decoder.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/spdy/hpack/hpack_constants.h" | 10 #include "net/spdy/hpack/hpack_constants.h" |
11 #include "net/spdy/hpack/hpack_output_stream.h" | 11 #include "net/spdy/hpack/hpack_output_stream.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 using base::StringPiece; | 15 using base::StringPiece; |
16 using std::string; | 16 using std::string; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kCookieKey[] = "cookie"; | 20 const char kCookieKey[] = "cookie"; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 HpackDecoder::HpackDecoder(const HpackHuffmanTable& table) | 24 HpackDecoder::HpackDecoder() |
25 : max_string_literal_size_(kDefaultMaxStringLiteralSize), | 25 : max_string_literal_size_(kDefaultMaxStringLiteralSize), |
26 huffman_table_(table), | |
27 handler_(nullptr), | 26 handler_(nullptr), |
28 regular_header_seen_(false), | 27 regular_header_seen_(false), |
29 header_block_started_(false) {} | 28 header_block_started_(false) {} |
30 | 29 |
31 HpackDecoder::~HpackDecoder() {} | 30 HpackDecoder::~HpackDecoder() {} |
32 | 31 |
33 bool HpackDecoder::HandleControlFrameHeadersData(const char* headers_data, | 32 bool HpackDecoder::HandleControlFrameHeadersData(const char* headers_data, |
34 size_t headers_data_length) { | 33 size_t headers_data_length) { |
35 decoded_block_.clear(); | 34 decoded_block_.clear(); |
36 if (!header_block_started_) { | 35 if (!header_block_started_) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 *next_name = key_buffer_; | 201 *next_name = key_buffer_; |
203 } | 202 } |
204 return true; | 203 return true; |
205 } | 204 } |
206 | 205 |
207 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream, | 206 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream, |
208 bool is_key, | 207 bool is_key, |
209 StringPiece* output) { | 208 StringPiece* output) { |
210 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) { | 209 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) { |
211 string* buffer = is_key ? &key_buffer_ : &value_buffer_; | 210 string* buffer = is_key ? &key_buffer_ : &value_buffer_; |
212 bool result = input_stream->DecodeNextHuffmanString(huffman_table_, buffer); | 211 bool result = input_stream->DecodeNextHuffmanString(buffer); |
213 *output = StringPiece(*buffer); | 212 *output = StringPiece(*buffer); |
214 return result; | 213 return result; |
215 } | 214 } |
216 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { | 215 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { |
217 return input_stream->DecodeNextIdentityString(output); | 216 return input_stream->DecodeNextIdentityString(output); |
218 } | 217 } |
219 return false; | 218 return false; |
220 } | 219 } |
221 | 220 |
222 } // namespace net | 221 } // namespace net |
OLD | NEW |