OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/spdy/header_coalescer.h" |
| 6 |
| 7 #include "base/strings/string_util.h" |
| 8 |
| 9 namespace net { |
| 10 |
| 11 void HeaderCoalescer::OnHeader(base::StringPiece key, base::StringPiece value) { |
| 12 if (key.empty()) { |
| 13 DVLOG(1) << "Header name must not be empty."; |
| 14 error_seen_ = true; |
| 15 return; |
| 16 } |
| 17 |
| 18 auto iter = headers_.find(key); |
| 19 if (iter == headers_.end()) { |
| 20 headers_[key] = value; |
| 21 } else { |
| 22 // This header had multiple values, so it must be reconstructed. |
| 23 base::StringPiece v = iter->second; |
| 24 std::string s(v.data(), v.length()); |
| 25 if (key == "cookie") { |
| 26 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. |
| 27 s.append("; "); |
| 28 } else { |
| 29 base::StringPiece("\0", 1).AppendToString(&s); |
| 30 } |
| 31 value.AppendToString(&s); |
| 32 headers_.ReplaceOrAppendHeader(key, s); |
| 33 } |
| 34 } |
| 35 |
| 36 } // namespace net |
OLD | NEW |