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

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: Created 5 years, 2 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
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // named |name|. 73 // named |name|.
74 static bool IsSafeHeader(const std::string& name); 74 static bool IsSafeHeader(const std::string& name);
75 75
76 // Returns true if |name| is a valid HTTP header name. 76 // Returns true if |name| is a valid HTTP header name.
77 static bool IsValidHeaderName(const std::string& name); 77 static bool IsValidHeaderName(const std::string& name);
78 78
79 // Returns false if |value| contains NUL or CRLF. This method does not perform 79 // Returns false if |value| contains NUL or CRLF. This method does not perform
80 // a fully RFC-2616-compliant header value validation. 80 // a fully RFC-2616-compliant header value validation.
81 static bool IsValidHeaderValue(const std::string& value); 81 static bool IsValidHeaderValue(const std::string& value);
82 82
83 // Returns true if the string is a valid HTTP header value according to
84 // RFC 7230 and doesn't contain CR or LF.
85 // i.e. returns true if the string matches |*field-content| in RFC 7230.
86 static bool IsValidHeaderValueRFC7230(const std::string& value);
87 static bool IsValidHeaderValueRFC7230(std::string::const_iterator value_begin,
88 std::string::const_iterator value_end);
davidben 2015/09/29 16:32:59 This should use a base::StringPiece. Then you don'
hiroshige 2015/09/30 08:19:23 Done.
89
83 // Strips all header lines from |headers| whose name matches 90 // Strips all header lines from |headers| whose name matches
84 // |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
85 // lower-case header names, with array length |headers_to_remove_len|. 92 // lower-case header names, with array length |headers_to_remove_len|.
86 // Returns the stripped header lines list, separated by "\r\n". 93 // Returns the stripped header lines list, separated by "\r\n".
87 static std::string StripHeaders(const std::string& headers, 94 static std::string StripHeaders(const std::string& headers,
88 const char* const headers_to_remove[], 95 const char* const headers_to_remove[],
89 size_t headers_to_remove_len); 96 size_t headers_to_remove_len);
90 97
91 // Multiple occurances of some headers cannot be coalesced into a comma- 98 // Multiple occurances of some headers cannot be coalesced into a comma-
92 // 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
383 390
384 // 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
385 // name is permitted to appear without a corresponding value. 392 // name is permitted to appear without a corresponding value.
386 bool values_optional_; 393 bool values_optional_;
387 }; 394 };
388 }; 395 };
389 396
390 } // namespace net 397 } // namespace net
391 398
392 #endif // NET_HTTP_HTTP_UTIL_H_ 399 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698