| 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> |
| 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 #include "net/http/http_version.h" |
| 17 | 18 |
| 18 // This is a macro to support extending this string literal at compile time. | 19 // This is a macro to support extending this string literal at compile time. |
| 19 // Please excuse me polluting your global namespace! | 20 // Please excuse me polluting your global namespace! |
| 20 #define HTTP_LWS " \t" | 21 #define HTTP_LWS " \t" |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 | 24 |
| 24 class NET_EXPORT HttpUtil { | 25 class NET_EXPORT HttpUtil { |
| 25 public: | 26 public: |
| 26 // Returns the absolute path of the URL, to be used for the http request. | 27 // Returns the absolute path of the URL, to be used for the http request. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // it will return 'utf-8,*;q=0.5'. Otherwise (e.g. 'euc-jp'), it'll return | 181 // it will return 'utf-8,*;q=0.5'. Otherwise (e.g. 'euc-jp'), it'll return |
| 181 // 'euc-jp,utf-8;q=0.7,*;q=0.3'. | 182 // 'euc-jp,utf-8;q=0.7,*;q=0.3'. |
| 182 static std::string GenerateAcceptCharsetHeader(const std::string& charset); | 183 static std::string GenerateAcceptCharsetHeader(const std::string& charset); |
| 183 | 184 |
| 184 // Helper. If |*headers| already contains |header_name| do nothing, | 185 // Helper. If |*headers| already contains |header_name| do nothing, |
| 185 // otherwise add <header_name> ": " <header_value> to the end of the list. | 186 // otherwise add <header_name> ": " <header_value> to the end of the list. |
| 186 static void AppendHeaderIfMissing(const char* header_name, | 187 static void AppendHeaderIfMissing(const char* header_name, |
| 187 const std::string& header_value, | 188 const std::string& header_value, |
| 188 std::string* headers); | 189 std::string* headers); |
| 189 | 190 |
| 191 // Returns true if the parameters describe a response with a strong etag or |
| 192 // last-modified header. See section 13.3.3 of RFC 2616. |
| 193 static bool HasStrongValidators(HttpVersion version, |
| 194 const std::string& etag_header, |
| 195 const std::string& last_modified_header, |
| 196 const std::string& date_header); |
| 197 |
| 190 // Used to iterate over the name/value pairs of HTTP headers. To iterate | 198 // Used to iterate over the name/value pairs of HTTP headers. To iterate |
| 191 // over the values in a multi-value header, use ValuesIterator. | 199 // over the values in a multi-value header, use ValuesIterator. |
| 192 // See AssembleRawHeaders for joining line continuations (this iterator | 200 // See AssembleRawHeaders for joining line continuations (this iterator |
| 193 // does not expect any). | 201 // does not expect any). |
| 194 class NET_EXPORT HeadersIterator { | 202 class NET_EXPORT HeadersIterator { |
| 195 public: | 203 public: |
| 196 HeadersIterator(std::string::const_iterator headers_begin, | 204 HeadersIterator(std::string::const_iterator headers_begin, |
| 197 std::string::const_iterator headers_end, | 205 std::string::const_iterator headers_end, |
| 198 const std::string& line_delimiter); | 206 const std::string& line_delimiter); |
| 199 ~HeadersIterator(); | 207 ~HeadersIterator(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // into the original's unquoted_value_ member. | 350 // into the original's unquoted_value_ member. |
| 343 std::string unquoted_value_; | 351 std::string unquoted_value_; |
| 344 | 352 |
| 345 bool value_is_quoted_; | 353 bool value_is_quoted_; |
| 346 }; | 354 }; |
| 347 }; | 355 }; |
| 348 | 356 |
| 349 } // namespace net | 357 } // namespace net |
| 350 | 358 |
| 351 #endif // NET_HTTP_HTTP_UTIL_H_ | 359 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |