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

Side by Side Diff: net/spdy/header_coalescer.cc

Issue 1961573002: Avoids the "re-encode HPACK as SPDY3" step. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoids the "re-encode HPACK as SPDY3" step. Created 4 years, 7 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
OLDNEW
(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 for (char c : key) {
19 if (base::IsAsciiUpper(c)) {
20 DLOG(ERROR) << "Malformed header: Header name " << key
21 << " contains upper-case characters.";
22 error_seen_ = true;
23 return;
24 }
25 }
26
27 auto iter = headers_.find(key);
28 if (iter == headers_.end()) {
29 headers_[key] = value;
30 } else if (key == "cookie") {
31 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction.
32 base::StringPiece v = iter->second;
33 std::string s(v.data(), v.length());
34 s.append("; ");
35 value.AppendToString(&s);
36 headers_.ReplaceOrAppendHeader(key, s);
37 } else {
38 // This header had multiple values, so it must be reconstructed.
39 base::StringPiece v = iter->second;
40 std::string s(v.data(), v.length());
41 base::StringPiece("\0", 1).AppendToString(&s);
42 value.AppendToString(&s);
43 headers_.ReplaceOrAppendHeader(key, s);
44 }
45 }
46
47 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698