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

Side by Side Diff: net/quic/spdy_utils.cc

Issue 1974673004: Joins Cookie header components correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@121398461
Patch Set: fixes for trybot detected errors 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
« no previous file with comments | « no previous file | net/quic/spdy_utils_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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/quic/spdy_utils.h" 5 #include "net/quic/spdy_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 if (std::any_of(name.begin(), name.end(), base::IsAsciiUpper<char>)) { 123 if (std::any_of(name.begin(), name.end(), base::IsAsciiUpper<char>)) {
124 DLOG(ERROR) << "Malformed header: Header name " << name 124 DLOG(ERROR) << "Malformed header: Header name " << name
125 << " contains upper-case characters."; 125 << " contains upper-case characters.";
126 return false; 126 return false;
127 } 127 }
128 128
129 auto iter = headers->find(name); 129 auto iter = headers->find(name);
130 if (iter == headers->end()) { 130 if (iter == headers->end()) {
131 (*headers)[name] = p.second; 131 (*headers)[name] = p.second;
132 } else if (name == "cookie") {
133 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction.
134 headers->ReplaceOrAppendHeader(
135 name, base::StringPrintf("%s; %s", iter->second.as_string().c_str(),
136 p.second.c_str()));
132 } else { 137 } else {
133 // This header had multiple values, so it must be reconstructed. 138 // This header had multiple values, so it must be reconstructed.
134 string value = base::StringPrintf( 139 string value = base::StringPrintf(
135 "%s%c%s", iter->second.as_string().c_str(), '\0', p.second.c_str()); 140 "%s%c%s", iter->second.as_string().c_str(), '\0', p.second.c_str());
136 headers->ReplaceOrAppendHeader(name, value); 141 headers->ReplaceOrAppendHeader(name, value);
137 } 142 }
138 } 143 }
139 144
140 if (ContainsKey(*headers, "content-length")) { 145 if (ContainsKey(*headers, "content-length")) {
141 // Check whether multiple values are consistent. 146 // Check whether multiple values are consistent.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return GURL(GetUrlFromHeaderBlock(headers)).host(); 248 return GURL(GetUrlFromHeaderBlock(headers)).host();
244 } 249 }
245 250
246 // static 251 // static
247 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { 252 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) {
248 string url(GetUrlFromHeaderBlock(headers)); 253 string url(GetUrlFromHeaderBlock(headers));
249 return url != "" && GURL(url).is_valid(); 254 return url != "" && GURL(url).is_valid();
250 } 255 }
251 256
252 } // namespace net 257 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/spdy_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698