OLD | NEW |
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 Loading... |
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 Loading... |
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_ |
OLD | NEW |