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 22 matching lines...) Expand all Loading... |
33 static std::string SpecForRequest(const GURL& url); | 33 static std::string SpecForRequest(const GURL& url); |
34 | 34 |
35 // Locates the next occurance of delimiter in line, skipping over quoted | 35 // Locates the next occurance of delimiter in line, skipping over quoted |
36 // strings (e.g., commas will not be treated as delimiters if they appear | 36 // strings (e.g., commas will not be treated as delimiters if they appear |
37 // within a quoted string). Returns the offset of the found delimiter or | 37 // within a quoted string). Returns the offset of the found delimiter or |
38 // line.size() if no delimiter was found. | 38 // line.size() if no delimiter was found. |
39 static size_t FindDelimiter(const std::string& line, | 39 static size_t FindDelimiter(const std::string& line, |
40 size_t search_start, | 40 size_t search_start, |
41 char delimiter); | 41 char delimiter); |
42 | 42 |
| 43 // Parses an "HTTP/X.Y" version from a string, such as: |
| 44 // "HTTP/1.1" |
| 45 // Returns whether or not the version string was successfully parsed. |
| 46 static bool ParseVersion(const std::string& version_str, |
| 47 HttpVersion* version); |
| 48 |
43 // Parses the value of a Content-Type header. The resulting mime_type and | 49 // Parses the value of a Content-Type header. The resulting mime_type and |
44 // charset values are normalized to lowercase. The mime_type and charset | 50 // charset values are normalized to lowercase. The mime_type and charset |
45 // output values are only modified if the content_type_str contains a mime | 51 // output values are only modified if the content_type_str contains a mime |
46 // type and charset value, respectively. The boundary output value is | 52 // type and charset value, respectively. The boundary output value is |
47 // optional and will be assigned the (quoted) value of the boundary | 53 // optional and will be assigned the (quoted) value of the boundary |
48 // paramter, if any. | 54 // paramter, if any. |
49 static void ParseContentType(const std::string& content_type_str, | 55 static void ParseContentType(const std::string& content_type_str, |
50 std::string* mime_type, | 56 std::string* mime_type, |
51 std::string* charset, | 57 std::string* charset, |
52 bool* had_charset, | 58 bool* had_charset, |
(...skipping 297 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 |