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

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

Issue 2184253002: Reset HTTP/2 stream on line-folded response headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « net/net.gypi ('k') | net/spdy/header_coalescer_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 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 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/header_coalescer.h" 5 #include "net/spdy/header_coalescer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 10
(...skipping 21 matching lines...) Expand all
32 32
33 if (key[0] == ':') { 33 if (key[0] == ':') {
34 if (regular_header_seen_) { 34 if (regular_header_seen_) {
35 error_seen_ = true; 35 error_seen_ = true;
36 return; 36 return;
37 } 37 }
38 } else { 38 } else {
39 regular_header_seen_ = true; 39 regular_header_seen_ = true;
40 } 40 }
41 41
42 // Line folding is forbidden by RFC 7230 Section 3.2.4.
Ryan Hamilton 2016/07/27 23:36:58 Can we simply check for \r\n? It seems like that's
Bence 2016/08/01 14:06:17 I agree. Done.
43 if (value.find("\r\n ") != base::StringPiece::npos ||
44 value.find("\r\n\t") != base::StringPiece::npos) {
45 error_seen_ = true;
46 return;
47 }
48
42 auto iter = headers_.find(key); 49 auto iter = headers_.find(key);
43 if (iter == headers_.end()) { 50 if (iter == headers_.end()) {
44 headers_[key] = value; 51 headers_[key] = value;
45 } else { 52 } else {
46 // This header had multiple values, so it must be reconstructed. 53 // This header had multiple values, so it must be reconstructed.
47 base::StringPiece v = iter->second; 54 base::StringPiece v = iter->second;
48 std::string s(v.data(), v.length()); 55 std::string s(v.data(), v.length());
49 if (key == "cookie") { 56 if (key == "cookie") {
50 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. 57 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction.
51 s.append("; "); 58 s.append("; ");
52 } else { 59 } else {
53 base::StringPiece("\0", 1).AppendToString(&s); 60 base::StringPiece("\0", 1).AppendToString(&s);
54 } 61 }
55 value.AppendToString(&s); 62 value.AppendToString(&s);
56 headers_.ReplaceOrAppendHeader(key, s); 63 headers_.ReplaceOrAppendHeader(key, s);
57 } 64 }
58 } 65 }
59 66
60 SpdyHeaderBlock HeaderCoalescer::release_headers() { 67 SpdyHeaderBlock HeaderCoalescer::release_headers() {
61 DCHECK(headers_valid_); 68 DCHECK(headers_valid_);
62 headers_valid_ = false; 69 headers_valid_ = false;
63 return std::move(headers_); 70 return std::move(headers_);
64 } 71 }
65 72
66 } // namespace net 73 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/spdy/header_coalescer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698