| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 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 the value of a Content-Type header. The resulting mime_type and | 43 // 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 | 44 // 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 | 45 // output values are only modified if the content_type_str contains a mime |
| 46 // type and charset value, respectively. | 46 // type and charset value, respectively. The boundary output value is |
| 47 // optional and will be assigned the (quoted) value of the boundary |
| 48 // paramter, if any. |
| 47 static void ParseContentType(const std::string& content_type_str, | 49 static void ParseContentType(const std::string& content_type_str, |
| 48 std::string* mime_type, | 50 std::string* mime_type, |
| 49 std::string* charset, | 51 std::string* charset, |
| 50 bool* had_charset); | 52 bool* had_charset, |
| 53 std::string* boundary); |
| 51 | 54 |
| 52 // Scans the headers and look for the first "Range" header in |headers|, | 55 // Scans the headers and look for the first "Range" header in |headers|, |
| 53 // if "Range" exists and the first one of it is well formatted then returns | 56 // if "Range" exists and the first one of it is well formatted then returns |
| 54 // true, |ranges| will contain a list of valid ranges. If return | 57 // true, |ranges| will contain a list of valid ranges. If return |
| 55 // value is false then values in |ranges| should not be used. The format of | 58 // value is false then values in |ranges| should not be used. The format of |
| 56 // "Range" header is defined in RFC 2616 Section 14.35.1. | 59 // "Range" header is defined in RFC 2616 Section 14.35.1. |
| 57 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 | 60 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 |
| 58 static bool ParseRanges(const std::string& headers, | 61 static bool ParseRanges(const std::string& headers, |
| 59 std::vector<HttpByteRange>* ranges); | 62 std::vector<HttpByteRange>* ranges); |
| 60 | 63 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // into the original's unquoted_value_ member. | 335 // into the original's unquoted_value_ member. |
| 333 std::string unquoted_value_; | 336 std::string unquoted_value_; |
| 334 | 337 |
| 335 bool value_is_quoted_; | 338 bool value_is_quoted_; |
| 336 }; | 339 }; |
| 337 }; | 340 }; |
| 338 | 341 |
| 339 } // namespace net | 342 } // namespace net |
| 340 | 343 |
| 341 #endif // NET_HTTP_HTTP_UTIL_H_ | 344 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |