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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/spdy/header_coalescer.cc
diff --git a/net/spdy/header_coalescer.cc b/net/spdy/header_coalescer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8e1bf5d184d6266a1d623d5e2aea4300c916dc2a
--- /dev/null
+++ b/net/spdy/header_coalescer.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/spdy/header_coalescer.h"
+
+#include "base/strings/string_util.h"
+
+namespace net {
+
+void HeaderCoalescer::OnHeader(base::StringPiece key, base::StringPiece value) {
+ if (key.empty()) {
+ DVLOG(1) << "Header name must not be empty.";
+ error_seen_ = true;
+ return;
+ }
+
+ for (char c : key) {
+ if (base::IsAsciiUpper(c)) {
+ DLOG(ERROR) << "Malformed header: Header name " << key
+ << " contains upper-case characters.";
+ error_seen_ = true;
+ return;
+ }
+ }
+
+ auto iter = headers_.find(key);
+ if (iter == headers_.end()) {
+ headers_[key] = value;
+ } else if (key == "cookie") {
+ // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction.
+ base::StringPiece v = iter->second;
+ std::string s(v.data(), v.length());
+ s.append("; ");
+ value.AppendToString(&s);
+ headers_.ReplaceOrAppendHeader(key, s);
+ } else {
+ // This header had multiple values, so it must be reconstructed.
+ base::StringPiece v = iter->second;
+ std::string s(v.data(), v.length());
+ base::StringPiece("\0", 1).AppendToString(&s);
+ value.AppendToString(&s);
+ headers_.ReplaceOrAppendHeader(key, s);
+ }
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698