| 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/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if (name.size() > 0) { | 68 if (name.size() > 0) { |
| 69 if (name[0] == kPseudoHeaderPrefix) { | 69 if (name[0] == kPseudoHeaderPrefix) { |
| 70 if (regular_header_seen_) { | 70 if (regular_header_seen_) { |
| 71 return false; | 71 return false; |
| 72 } | 72 } |
| 73 } else { | 73 } else { |
| 74 regular_header_seen_ = true; | 74 regular_header_seen_ = true; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 auto it = decoded_block_.find(name.as_string()); | 78 auto it = decoded_block_.find(name); |
| 79 if (it == decoded_block_.end()) { | 79 if (it == decoded_block_.end()) { |
| 80 // This is a new key. | 80 // This is a new key. |
| 81 decoded_block_[name.as_string()].assign(value.data(), value.size()); | 81 decoded_block_[name] = value; |
| 82 } else { | 82 } else { |
| 83 // The key already exists, append |value| with appropriate delimiter. | 83 // The key already exists, append |value| with appropriate delimiter. |
| 84 string& old_value = it->second; | 84 string new_value = it->second.as_string(); |
| 85 if (name == kCookieKey) { | 85 new_value.append((name == kCookieKey) ? "; " : string(1, '\0')); |
| 86 old_value.append("; "); | 86 value.AppendToString(&new_value); |
| 87 value.AppendToString(&old_value); | 87 decoded_block_.ReplaceOrAppendHeader(name, new_value); |
| 88 } else { | |
| 89 old_value.push_back('\0'); | |
| 90 old_value.insert(old_value.end(), value.begin(), value.end()); | |
| 91 } | |
| 92 } | 88 } |
| 93 return true; | 89 return true; |
| 94 } | 90 } |
| 95 | 91 |
| 96 bool HpackDecoder::DecodeNextOpcode(HpackInputStream* input_stream) { | 92 bool HpackDecoder::DecodeNextOpcode(HpackInputStream* input_stream) { |
| 97 // Implements 7.1: Indexed Header Field Representation. | 93 // Implements 7.1: Indexed Header Field Representation. |
| 98 if (input_stream->MatchPrefixAndConsume(kIndexedOpcode)) { | 94 if (input_stream->MatchPrefixAndConsume(kIndexedOpcode)) { |
| 99 return DecodeNextIndexedHeader(input_stream); | 95 return DecodeNextIndexedHeader(input_stream); |
| 100 } | 96 } |
| 101 // Implements 7.2.1: Literal Header Field with Incremental Indexing. | 97 // Implements 7.2.1: Literal Header Field with Incremental Indexing. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 *output = StringPiece(*buffer); | 200 *output = StringPiece(*buffer); |
| 205 return result; | 201 return result; |
| 206 } | 202 } |
| 207 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { | 203 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { |
| 208 return input_stream->DecodeNextIdentityString(output); | 204 return input_stream->DecodeNextIdentityString(output); |
| 209 } | 205 } |
| 210 return false; | 206 return false; |
| 211 } | 207 } |
| 212 | 208 |
| 213 } // namespace net | 209 } // namespace net |
| OLD | NEW |