| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/string_tokenizer.h" | 13 #include "base/string_tokenizer.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/http/http_byte_range.h" | 16 #include "net/http/http_byte_range.h" |
| 17 | 17 |
| 18 // This is a macro to support extending this string literal at compile time. | 18 // This is a macro to support extending this string literal at compile time. |
| 19 // Please excuse me polluting your global namespace! | 19 // Please excuse me polluting your global namespace! |
| 20 #define HTTP_LWS " \t" | 20 #define HTTP_LWS " \t" |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 | 23 |
| 24 class UploadDataStream; | |
| 25 | |
| 26 class NET_EXPORT HttpUtil { | 24 class NET_EXPORT HttpUtil { |
| 27 public: | 25 public: |
| 28 // Returns the absolute path of the URL, to be used for the http request. | 26 // Returns the absolute path of the URL, to be used for the http request. |
| 29 // The absolute path starts with a '/' and may contain a query. | 27 // The absolute path starts with a '/' and may contain a query. |
| 30 static std::string PathForRequest(const GURL& url); | 28 static std::string PathForRequest(const GURL& url); |
| 31 | 29 |
| 32 // Returns the absolute URL, to be used for the http request. This url is | 30 // Returns the absolute URL, to be used for the http request. This url is |
| 33 // made up of the protocol, host, [port], path, [query]. Everything else | 31 // made up of the protocol, host, [port], path, [query]. Everything else |
| 34 // is stripped (username, password, reference). | 32 // is stripped (username, password, reference). |
| 35 static std::string SpecForRequest(const GURL& url); | 33 static std::string SpecForRequest(const GURL& url); |
| 36 | 34 |
| 37 // Locates the next occurance of delimiter in line, skipping over quoted | 35 // Locates the next occurance of delimiter in line, skipping over quoted |
| 38 // 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 |
| 39 // 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 |
| 40 // line.size() if no delimiter was found. | 38 // line.size() if no delimiter was found. |
| 41 static size_t FindDelimiter(const std::string& line, | 39 static size_t FindDelimiter(const std::string& line, |
| 42 size_t search_start, | 40 size_t search_start, |
| 43 char delimiter); | 41 char delimiter); |
| 44 | 42 |
| 45 // 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 |
| 46 // charset values are normalized to lowercase. The mime_type and charset | 44 // charset values are normalized to lowercase. The mime_type and charset |
| 47 // 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 |
| 48 // type and charset value, respectively. | 46 // type and charset value, respectively. |
| 49 static void ParseContentType(const std::string& content_type_str, | 47 static void ParseContentType(const std::string& content_type_str, |
| 50 std::string* mime_type, | 48 std::string* mime_type, |
| 51 std::string* charset, | 49 std::string* charset, |
| 52 bool *had_charset); | 50 bool* had_charset); |
| 53 | 51 |
| 54 // Scans the headers and look for the first "Range" header in |headers|, | 52 // Scans the headers and look for the first "Range" header in |headers|, |
| 55 // if "Range" exists and the first one of it is well formatted then returns | 53 // if "Range" exists and the first one of it is well formatted then returns |
| 56 // true, |ranges| will contain a list of valid ranges. If return | 54 // true, |ranges| will contain a list of valid ranges. If return |
| 57 // value is false then values in |ranges| should not be used. The format of | 55 // value is false then values in |ranges| should not be used. The format of |
| 58 // "Range" header is defined in RFC 2616 Section 14.35.1. | 56 // "Range" header is defined in RFC 2616 Section 14.35.1. |
| 59 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 | 57 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 |
| 60 static bool ParseRanges(const std::string& headers, | 58 static bool ParseRanges(const std::string& headers, |
| 61 std::vector<HttpByteRange>* ranges); | 59 std::vector<HttpByteRange>* ranges); |
| 62 | 60 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // into the original's unquoted_value_ member. | 328 // into the original's unquoted_value_ member. |
| 331 std::string unquoted_value_; | 329 std::string unquoted_value_; |
| 332 | 330 |
| 333 bool value_is_quoted_; | 331 bool value_is_quoted_; |
| 334 }; | 332 }; |
| 335 }; | 333 }; |
| 336 | 334 |
| 337 } // namespace net | 335 } // namespace net |
| 338 | 336 |
| 339 #endif // NET_HTTP_HTTP_UTIL_H_ | 337 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |