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

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

Issue 2624213002: net: remove AppendHeaderIfMissing() from HttpUtil (Closed)
Patch Set: Created 3 years, 11 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
« 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 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // Parses a Retry-After header that is either an absolute date/time or a 68 // Parses a Retry-After header that is either an absolute date/time or a
69 // number of seconds in the future. Interprets absolute times as relative to 69 // number of seconds in the future. Interprets absolute times as relative to
70 // |now|. If |retry_after_string| is successfully parsed and indicates a time 70 // |now|. If |retry_after_string| is successfully parsed and indicates a time
71 // that is not in the past, fills in |*retry_after| and returns true; 71 // that is not in the past, fills in |*retry_after| and returns true;
72 // otherwise, returns false. 72 // otherwise, returns false.
73 static bool ParseRetryAfterHeader(const std::string& retry_after_string, 73 static bool ParseRetryAfterHeader(const std::string& retry_after_string,
74 base::Time now, 74 base::Time now,
75 base::TimeDelta* retry_after); 75 base::TimeDelta* retry_after);
76 76
77 // Scans the '\r\n'-delimited headers for the given header name. Returns
78 // true if a match is found. Input is assumed to be well-formed.
79 // TODO(darin): kill this
80 static bool HasHeader(const std::string& headers, const char* name);
81
82 // Returns true if it is safe to allow users and scripts to specify the header 77 // Returns true if it is safe to allow users and scripts to specify the header
83 // named |name|. 78 // named |name|.
84 static bool IsSafeHeader(const std::string& name); 79 static bool IsSafeHeader(const std::string& name);
85 80
86 // Returns true if |name| is a valid HTTP header name. 81 // Returns true if |name| is a valid HTTP header name.
87 static bool IsValidHeaderName(const base::StringPiece& name); 82 static bool IsValidHeaderName(const base::StringPiece& name);
88 83
89 // Returns false if |value| contains NUL or CRLF. This method does not perform 84 // Returns false if |value| contains NUL or CRLF. This method does not perform
90 // a fully RFC-2616-compliant header value validation. 85 // a fully RFC-2616-compliant header value validation.
91 static bool IsValidHeaderValue(const base::StringPiece& value); 86 static bool IsValidHeaderValue(const base::StringPiece& value);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // means q=1.0. 198 // means q=1.0.
204 // 199 //
205 // When making a http request, this should be used to determine what 200 // When making a http request, this should be used to determine what
206 // to put in Accept-Language header. If a comma separated list of language 201 // to put in Accept-Language header. If a comma separated list of language
207 // codes *without* qvalue is sent, web servers regard all 202 // codes *without* qvalue is sent, web servers regard all
208 // of them as having q=1.0 and pick one of them even though it may not 203 // of them as having q=1.0 and pick one of them even though it may not
209 // be at the beginning of the list (see http://crbug.com/5899). 204 // be at the beginning of the list (see http://crbug.com/5899).
210 static std::string GenerateAcceptLanguageHeader( 205 static std::string GenerateAcceptLanguageHeader(
211 const std::string& raw_language_list); 206 const std::string& raw_language_list);
212 207
213 // Helper. If |*headers| already contains |header_name| do nothing,
214 // otherwise add <header_name> ": " <header_value> to the end of the list.
215 static void AppendHeaderIfMissing(const char* header_name,
216 const std::string& header_value,
217 std::string* headers);
218
219 // Returns true if the parameters describe a response with a strong etag or 208 // Returns true if the parameters describe a response with a strong etag or
220 // last-modified header. See section 13.3.3 of RFC 2616. 209 // last-modified header. See section 13.3.3 of RFC 2616.
221 // An empty string should be passed for missing headers. 210 // An empty string should be passed for missing headers.
222 static bool HasStrongValidators(HttpVersion version, 211 static bool HasStrongValidators(HttpVersion version,
223 const std::string& etag_header, 212 const std::string& etag_header,
224 const std::string& last_modified_header, 213 const std::string& last_modified_header,
225 const std::string& date_header); 214 const std::string& date_header);
226 215
227 // Returns true if this response has any validator (either a Last-Modified or 216 // Returns true if this response has any validator (either a Last-Modified or
228 // an ETag) regardless of whether it is strong or weak. See section 13.3.3 of 217 // an ETag) regardless of whether it is strong or weak. See section 13.3.3 of
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // True if quotes values are required to be properly quoted; false if 425 // True if quotes values are required to be properly quoted; false if
437 // mismatched quotes and other problems with quoted values should be more 426 // mismatched quotes and other problems with quoted values should be more
438 // or less gracefully treated as valid. 427 // or less gracefully treated as valid.
439 bool strict_quotes_; 428 bool strict_quotes_;
440 }; 429 };
441 }; 430 };
442 431
443 } // namespace net 432 } // namespace net
444 433
445 #endif // NET_HTTP_HTTP_UTIL_H_ 434 #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