Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Side by Side Diff: net/spdy/hpack/hpack_decoder.cc

Issue 2026593002: Remove limit on individual hpack string literals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused include. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/hpack/hpack_decoder.h ('k') | net/spdy/hpack/hpack_decoder_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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() 24 HpackDecoder::HpackDecoder()
25 : max_string_literal_size_(kDefaultMaxStringLiteralSize), 25 : handler_(nullptr),
26 handler_(nullptr),
27 total_header_bytes_(0), 26 total_header_bytes_(0),
28 regular_header_seen_(false), 27 regular_header_seen_(false),
29 header_block_started_(false), 28 header_block_started_(false),
30 total_parsed_bytes_(0) {} 29 total_parsed_bytes_(0) {}
31 30
32 HpackDecoder::~HpackDecoder() {} 31 HpackDecoder::~HpackDecoder() {}
33 32
34 bool HpackDecoder::HandleControlFrameHeadersData(const char* headers_data, 33 bool HpackDecoder::HandleControlFrameHeadersData(const char* headers_data,
35 size_t headers_data_length) { 34 size_t headers_data_length) {
36 if (!header_block_started_) { 35 if (!header_block_started_) {
37 decoded_block_.clear(); 36 decoded_block_.clear();
38 if (handler_ != nullptr) { 37 if (handler_ != nullptr) {
39 handler_->OnHeaderBlockStart(); 38 handler_->OnHeaderBlockStart();
40 } 39 }
41 } 40 }
42 size_t new_size = headers_block_buffer_.size() + headers_data_length; 41 size_t new_size = headers_block_buffer_.size() + headers_data_length;
43 if (new_size > kMaxDecodeBufferSize) { 42 if (new_size > kMaxDecodeBufferSize) {
44 return false; 43 return false;
45 } 44 }
46 headers_block_buffer_.insert(headers_block_buffer_.end(), headers_data, 45 headers_block_buffer_.insert(headers_block_buffer_.end(), headers_data,
47 headers_data + headers_data_length); 46 headers_data + headers_data_length);
48 47
49 // Parse as many data in buffer as possible. And remove the parsed data 48 // Parse as many data in buffer as possible. And remove the parsed data
50 // from buffer. 49 // from buffer.
51 HpackInputStream input_stream(max_string_literal_size_, 50 HpackInputStream input_stream(headers_block_buffer_);
52 headers_block_buffer_);
53 51
54 // If this is the start of the header block, process table size updates. 52 // If this is the start of the header block, process table size updates.
55 if (!header_block_started_) { 53 if (!header_block_started_) {
56 if (!DecodeAtMostTwoHeaderTableSizeUpdates(&input_stream)) { 54 if (!DecodeAtMostTwoHeaderTableSizeUpdates(&input_stream)) {
57 return false; 55 return false;
58 } 56 }
59 input_stream.MarkCurrentPosition(); 57 input_stream.MarkCurrentPosition();
60 } 58 }
61 while (input_stream.HasMoreData()) { 59 while (input_stream.HasMoreData()) {
62 if (!DecodeNextOpcodeWrapper(&input_stream)) { 60 if (!DecodeNextOpcodeWrapper(&input_stream)) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 *output = StringPiece(*buffer); 273 *output = StringPiece(*buffer);
276 return result; 274 return result;
277 } 275 }
278 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { 276 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) {
279 return input_stream->DecodeNextIdentityString(output); 277 return input_stream->DecodeNextIdentityString(output);
280 } 278 }
281 return false; 279 return false;
282 } 280 }
283 281
284 } // namespace net 282 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_decoder.h ('k') | net/spdy/hpack/hpack_decoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698