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 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // TODO(crbug.com/671799): Should remove or internalize this to | 204 // TODO(crbug.com/671799): Should remove or internalize this to |
205 // HttpResponseHeaders. | 205 // HttpResponseHeaders. |
206 static std::string AssembleRawHeaders(const char* buf, int buf_len); | 206 static std::string AssembleRawHeaders(const char* buf, int buf_len); |
207 | 207 |
208 // Converts assembled "raw headers" back to the HTTP response format. That is | 208 // Converts assembled "raw headers" back to the HTTP response format. That is |
209 // convert each \0 occurence to CRLF. This is used by DevTools. | 209 // convert each \0 occurence to CRLF. This is used by DevTools. |
210 // Since all line continuations info is already lost at this point, the result | 210 // Since all line continuations info is already lost at this point, the result |
211 // consists of status line and then one line for each header. | 211 // consists of status line and then one line for each header. |
212 static std::string ConvertHeadersBackToHTTPResponse(const std::string& str); | 212 static std::string ConvertHeadersBackToHTTPResponse(const std::string& str); |
213 | 213 |
214 // Given a comma separated ordered list of language codes, return | |
215 // the list with a qvalue appended to each language. | |
216 // The way qvalues are assigned is rather simple. The qvalue | |
217 // starts with 1.0 and is decremented by 0.2 for each successive entry | |
218 // in the list until it reaches 0.2. All the entries after that are | |
219 // assigned the same qvalue of 0.2. Also, note that the 1st language | |
220 // will not have a qvalue added because the absence of a qvalue implicitly | |
221 // means q=1.0. | |
222 // | |
223 // When making a http request, this should be used to determine what | |
224 // to put in Accept-Language header. If a comma separated list of language | |
225 // codes *without* qvalue is sent, web servers regard all | |
226 // of them as having q=1.0 and pick one of them even though it may not | |
227 // be at the beginning of the list (see http://crbug.com/5899). | |
228 static std::string GenerateAcceptLanguageHeader( | |
229 const std::string& raw_language_list); | |
230 | |
231 // Helper. If |*headers| already contains |header_name| do nothing, | 214 // Helper. If |*headers| already contains |header_name| do nothing, |
232 // otherwise add <header_name> ": " <header_value> to the end of the list. | 215 // otherwise add <header_name> ": " <header_value> to the end of the list. |
233 static void AppendHeaderIfMissing(const char* header_name, | 216 static void AppendHeaderIfMissing(const char* header_name, |
234 const std::string& header_value, | 217 const std::string& header_value, |
235 std::string* headers); | 218 std::string* headers); |
236 | 219 |
237 // Returns true if the parameters describe a response with a strong etag or | 220 // Returns true if the parameters describe a response with a strong etag or |
238 // last-modified header. See section 13.3.3 of RFC 2616. | 221 // last-modified header. See section 13.3.3 of RFC 2616. |
239 // An empty string should be passed for missing headers. | 222 // An empty string should be passed for missing headers. |
240 static bool HasStrongValidators(HttpVersion version, | 223 static bool HasStrongValidators(HttpVersion version, |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 // True if quotes values are required to be properly quoted; false if | 437 // True if quotes values are required to be properly quoted; false if |
455 // mismatched quotes and other problems with quoted values should be more | 438 // mismatched quotes and other problems with quoted values should be more |
456 // or less gracefully treated as valid. | 439 // or less gracefully treated as valid. |
457 bool strict_quotes_; | 440 bool strict_quotes_; |
458 }; | 441 }; |
459 }; | 442 }; |
460 | 443 |
461 } // namespace net | 444 } // namespace net |
462 | 445 |
463 #endif // NET_HTTP_HTTP_UTIL_H_ | 446 #endif // NET_HTTP_HTTP_UTIL_H_ |
OLD | NEW |