Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 68 |
| 69 // Scans the '\r\n'-delimited headers for the given header name. Returns | 69 // Scans the '\r\n'-delimited headers for the given header name. Returns |
| 70 // true if a match is found. Input is assumed to be well-formed. | 70 // true if a match is found. Input is assumed to be well-formed. |
| 71 // TODO(darin): kill this | 71 // TODO(darin): kill this |
| 72 static bool HasHeader(const std::string& headers, const char* name); | 72 static bool HasHeader(const std::string& headers, const char* name); |
| 73 | 73 |
| 74 // Returns true if it is safe to allow users and scripts to specify the header | 74 // Returns true if it is safe to allow users and scripts to specify the header |
| 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. | |
| 79 static bool IsValidHeaderName(const std::string& name); | |
| 80 | |
| 81 // Returns true if |value| is a valid HTTP header value. | |
|
mmenke
2014/08/25 16:32:44
This isn't accurate. It doesn't do a full validat
robwu
2014/08/25 18:58:29
Done.
| |
| 82 static bool IsValidHeaderValue(const std::string& value); | |
| 83 | |
| 78 // Strips all header lines from |headers| whose name matches | 84 // Strips all header lines from |headers| whose name matches |
| 79 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated | 85 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated |
| 80 // lower-case header names, with array length |headers_to_remove_len|. | 86 // lower-case header names, with array length |headers_to_remove_len|. |
| 81 // Returns the stripped header lines list, separated by "\r\n". | 87 // Returns the stripped header lines list, separated by "\r\n". |
| 82 static std::string StripHeaders(const std::string& headers, | 88 static std::string StripHeaders(const std::string& headers, |
| 83 const char* const headers_to_remove[], | 89 const char* const headers_to_remove[], |
| 84 size_t headers_to_remove_len); | 90 size_t headers_to_remove_len); |
| 85 | 91 |
| 86 // Multiple occurances of some headers cannot be coalesced into a comma- | 92 // Multiple occurances of some headers cannot be coalesced into a comma- |
| 87 // separated list since their values are (or contain) unquoted HTTP-date | 93 // separated list since their values are (or contain) unquoted HTTP-date |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 // into the original's unquoted_value_ member. | 356 // into the original's unquoted_value_ member. |
| 351 std::string unquoted_value_; | 357 std::string unquoted_value_; |
| 352 | 358 |
| 353 bool value_is_quoted_; | 359 bool value_is_quoted_; |
| 354 }; | 360 }; |
| 355 }; | 361 }; |
| 356 | 362 |
| 357 } // namespace net | 363 } // namespace net |
| 358 | 364 |
| 359 #endif // NET_HTTP_HTTP_UTIL_H_ | 365 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |