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

Side by Side Diff: net/http/http_util.h

Issue 1374883002: Add UMAs for checking header values against RFC 7230 in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect comments Created 5 years 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/http/http_util.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_HTTP_HTTP_UTIL_H_ 5 #ifndef NET_HTTP_HTTP_UTIL_H_
6 #define NET_HTTP_HTTP_UTIL_H_ 6 #define NET_HTTP_HTTP_UTIL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // named |name|. 75 // named |name|.
76 static bool IsSafeHeader(const std::string& name); 76 static bool IsSafeHeader(const std::string& name);
77 77
78 // Returns true if |name| is a valid HTTP header name. 78 // Returns true if |name| is a valid HTTP header name.
79 static bool IsValidHeaderName(const std::string& name); 79 static bool IsValidHeaderName(const std::string& name);
80 80
81 // Returns false if |value| contains NUL or CRLF. This method does not perform 81 // Returns false if |value| contains NUL or CRLF. This method does not perform
82 // a fully RFC-2616-compliant header value validation. 82 // a fully RFC-2616-compliant header value validation.
83 static bool IsValidHeaderValue(const std::string& value); 83 static bool IsValidHeaderValue(const std::string& value);
84 84
85 // Returns true if |value| is a valid HTTP header value according to
86 // RFC 7230 and doesn't contain CR or LF.
87 // i.e. returns true if |value| matches |*field-content| in RFC 7230.
88 static bool IsValidHeaderValueRFC7230(const base::StringPiece& value);
89
85 // Strips all header lines from |headers| whose name matches 90 // Strips all header lines from |headers| whose name matches
86 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated 91 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated
87 // lower-case header names, with array length |headers_to_remove_len|. 92 // lower-case header names, with array length |headers_to_remove_len|.
88 // Returns the stripped header lines list, separated by "\r\n". 93 // Returns the stripped header lines list, separated by "\r\n".
89 static std::string StripHeaders(const std::string& headers, 94 static std::string StripHeaders(const std::string& headers,
90 const char* const headers_to_remove[], 95 const char* const headers_to_remove[],
91 size_t headers_to_remove_len); 96 size_t headers_to_remove_len);
92 97
93 // Multiple occurances of some headers cannot be coalesced into a comma- 98 // Multiple occurances of some headers cannot be coalesced into a comma-
94 // separated list since their values are (or contain) unquoted HTTP-date 99 // separated list since their values are (or contain) unquoted HTTP-date
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 390
386 // True if values are required for each name/value pair; false if a 391 // True if values are required for each name/value pair; false if a
387 // name is permitted to appear without a corresponding value. 392 // name is permitted to appear without a corresponding value.
388 bool values_optional_; 393 bool values_optional_;
389 }; 394 };
390 }; 395 };
391 396
392 } // namespace net 397 } // namespace net
393 398
394 #endif // NET_HTTP_HTTP_UTIL_H_ 399 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698