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

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: Use StringPiece. 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 |value| is a valid HTTP header value according to
84 // RFC 7230 and doesn't contain CR or LF.
85 // i.e. returns true if |value| matches |*field-content| in RFC 7230.
86 static bool IsValidHeaderValueRFC7230(base::StringPiece value);
87
83 // Strips all header lines from |headers| whose name matches 88 // Strips all header lines from |headers| whose name matches
84 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated 89 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated
85 // lower-case header names, with array length |headers_to_remove_len|. 90 // lower-case header names, with array length |headers_to_remove_len|.
86 // Returns the stripped header lines list, separated by "\r\n". 91 // Returns the stripped header lines list, separated by "\r\n".
87 static std::string StripHeaders(const std::string& headers, 92 static std::string StripHeaders(const std::string& headers,
88 const char* const headers_to_remove[], 93 const char* const headers_to_remove[],
89 size_t headers_to_remove_len); 94 size_t headers_to_remove_len);
90 95
91 // Multiple occurances of some headers cannot be coalesced into a comma- 96 // Multiple occurances of some headers cannot be coalesced into a comma-
92 // separated list since their values are (or contain) unquoted HTTP-date 97 // separated list since their values are (or contain) unquoted HTTP-date
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 388
384 // True if values are required for each name/value pair; false if a 389 // True if values are required for each name/value pair; false if a
385 // name is permitted to appear without a corresponding value. 390 // name is permitted to appear without a corresponding value.
386 bool values_optional_; 391 bool values_optional_;
387 }; 392 };
388 }; 393 };
389 394
390 } // namespace net 395 } // namespace net
391 396
392 #endif // NET_HTTP_HTTP_UTIL_H_ 397 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_util.cc » ('j') | net/http/http_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698