Chromium Code Reviews| 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" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 total_parsed_bytes_ = 0; | 94 total_parsed_bytes_ = 0; |
| 95 header_block_started_ = false; | 95 header_block_started_ = false; |
| 96 handler_ = nullptr; | 96 handler_ = nullptr; |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool HpackDecoder::HandleHeaderRepresentation(StringPiece name, | 100 bool HpackDecoder::HandleHeaderRepresentation(StringPiece name, |
| 101 StringPiece value) { | 101 StringPiece value) { |
| 102 total_header_bytes_ += name.size() + value.size(); | 102 total_header_bytes_ += name.size() + value.size(); |
| 103 | 103 |
| 104 // Fail if pseudo-header follows regular header. | |
| 105 if (name.size() > 0) { | |
| 106 if (name[0] == kPseudoHeaderPrefix) { | |
| 107 if (regular_header_seen_) { | |
|
Bence
2016/05/31 15:57:01
Please also remove regular_header_seen_ member fro
| |
| 108 return false; | |
| 109 } | |
| 110 } else { | |
| 111 regular_header_seen_ = true; | |
| 112 } | |
| 113 } | |
| 114 | |
| 115 if (handler_ == nullptr) { | 104 if (handler_ == nullptr) { |
| 116 auto it = decoded_block_.find(name); | 105 auto it = decoded_block_.find(name); |
| 117 if (it == decoded_block_.end()) { | 106 if (it == decoded_block_.end()) { |
| 118 // This is a new key. | 107 // This is a new key. |
| 119 decoded_block_[name] = value; | 108 decoded_block_[name] = value; |
| 120 } else { | 109 } else { |
| 121 // The key already exists, append |value| with appropriate delimiter. | 110 // The key already exists, append |value| with appropriate delimiter. |
| 122 string new_value = it->second.as_string(); | 111 string new_value = it->second.as_string(); |
| 123 new_value.append((name == kCookieKey) ? "; " : string(1, '\0')); | 112 new_value.append((name == kCookieKey) ? "; " : string(1, '\0')); |
| 124 value.AppendToString(&new_value); | 113 value.AppendToString(&new_value); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 *output = StringPiece(*buffer); | 264 *output = StringPiece(*buffer); |
| 276 return result; | 265 return result; |
| 277 } | 266 } |
| 278 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { | 267 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { |
| 279 return input_stream->DecodeNextIdentityString(output); | 268 return input_stream->DecodeNextIdentityString(output); |
| 280 } | 269 } |
| 281 return false; | 270 return false; |
| 282 } | 271 } |
| 283 | 272 |
| 284 } // namespace net | 273 } // namespace net |
| OLD | NEW |