| OLD | NEW |
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 bool SpdyUtils::CopyAndValidateHeaders(const QuicHeaderList& header_list, | 113 bool SpdyUtils::CopyAndValidateHeaders(const QuicHeaderList& header_list, |
| 114 int64_t* content_length, | 114 int64_t* content_length, |
| 115 SpdyHeaderBlock* headers) { | 115 SpdyHeaderBlock* headers) { |
| 116 for (const auto& p : header_list) { | 116 for (const auto& p : header_list) { |
| 117 const string& name = p.first; | 117 const string& name = p.first; |
| 118 if (name.empty()) { | 118 if (name.empty()) { |
| 119 DVLOG(1) << "Header name must not be empty."; | 119 DVLOG(1) << "Header name must not be empty."; |
| 120 return false; | 120 return false; |
| 121 } | 121 } |
| 122 | 122 |
| 123 if (std::any_of(name.begin(), name.end(), base::IsAsciiUpper<char>)) { | |
| 124 DLOG(ERROR) << "Malformed header: Header name " << name | |
| 125 << " contains upper-case characters."; | |
| 126 return false; | |
| 127 } | |
| 128 | |
| 129 auto iter = headers->find(name); | 123 auto iter = headers->find(name); |
| 130 if (iter == headers->end()) { | 124 if (iter == headers->end()) { |
| 131 (*headers)[name] = p.second; | 125 (*headers)[name] = p.second; |
| 132 } else { | 126 } else { |
| 133 // This header had multiple values, so it must be reconstructed. | 127 // This header had multiple values, so it must be reconstructed. |
| 134 StringPiece v = iter->second; | 128 StringPiece v = iter->second; |
| 135 string s(v.data(), v.length()); | 129 string s(v.data(), v.length()); |
| 136 if (name == "cookie") { | 130 if (name == "cookie") { |
| 137 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. | 131 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. |
| 138 s.append("; "); | 132 s.append("; "); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return GURL(GetUrlFromHeaderBlock(headers)).host(); | 244 return GURL(GetUrlFromHeaderBlock(headers)).host(); |
| 251 } | 245 } |
| 252 | 246 |
| 253 // static | 247 // static |
| 254 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { | 248 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { |
| 255 string url(GetUrlFromHeaderBlock(headers)); | 249 string url(GetUrlFromHeaderBlock(headers)); |
| 256 return url != "" && GURL(url).is_valid(); | 250 return url != "" && GURL(url).is_valid(); |
| 257 } | 251 } |
| 258 | 252 |
| 259 } // namespace net | 253 } // namespace net |
| OLD | NEW |