| 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 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/string_tokenizer.h" | 12 #include "base/strings/string_tokenizer.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 #include "net/http/http_byte_range.h" | 15 #include "net/http/http_byte_range.h" |
| 16 #include "net/http/http_version.h" | 16 #include "net/http/http_version.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 { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 return values_begin_; | 245 return values_begin_; |
| 246 } | 246 } |
| 247 std::string::const_iterator values_end() const { | 247 std::string::const_iterator values_end() const { |
| 248 return values_end_; | 248 return values_end_; |
| 249 } | 249 } |
| 250 std::string values() const { | 250 std::string values() const { |
| 251 return std::string(values_begin_, values_end_); | 251 return std::string(values_begin_, values_end_); |
| 252 } | 252 } |
| 253 | 253 |
| 254 private: | 254 private: |
| 255 StringTokenizer lines_; | 255 base::StringTokenizer lines_; |
| 256 std::string::const_iterator name_begin_; | 256 std::string::const_iterator name_begin_; |
| 257 std::string::const_iterator name_end_; | 257 std::string::const_iterator name_end_; |
| 258 std::string::const_iterator values_begin_; | 258 std::string::const_iterator values_begin_; |
| 259 std::string::const_iterator values_end_; | 259 std::string::const_iterator values_end_; |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 // Iterates over delimited values in an HTTP header. HTTP LWS is | 262 // Iterates over delimited values in an HTTP header. HTTP LWS is |
| 263 // automatically trimmed from the resulting values. | 263 // automatically trimmed from the resulting values. |
| 264 // | 264 // |
| 265 // When using this class to iterate over response header values, be aware that | 265 // When using this class to iterate over response header values, be aware that |
| (...skipping 19 matching lines...) Expand all Loading... |
| 285 return value_begin_; | 285 return value_begin_; |
| 286 } | 286 } |
| 287 std::string::const_iterator value_end() const { | 287 std::string::const_iterator value_end() const { |
| 288 return value_end_; | 288 return value_end_; |
| 289 } | 289 } |
| 290 std::string value() const { | 290 std::string value() const { |
| 291 return std::string(value_begin_, value_end_); | 291 return std::string(value_begin_, value_end_); |
| 292 } | 292 } |
| 293 | 293 |
| 294 private: | 294 private: |
| 295 StringTokenizer values_; | 295 base::StringTokenizer values_; |
| 296 std::string::const_iterator value_begin_; | 296 std::string::const_iterator value_begin_; |
| 297 std::string::const_iterator value_end_; | 297 std::string::const_iterator value_end_; |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 // Iterates over a delimited sequence of name-value pairs in an HTTP header. | 300 // Iterates over a delimited sequence of name-value pairs in an HTTP header. |
| 301 // Each pair consists of a token (the name), an equals sign, and either a | 301 // Each pair consists of a token (the name), an equals sign, and either a |
| 302 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside | 302 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside |
| 303 // of and between names, values, and delimiters. | 303 // of and between names, values, and delimiters. |
| 304 // | 304 // |
| 305 // String iterators returned from this class' methods may be invalidated upon | 305 // String iterators returned from this class' methods may be invalidated upon |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 // into the original's unquoted_value_ member. | 355 // into the original's unquoted_value_ member. |
| 356 std::string unquoted_value_; | 356 std::string unquoted_value_; |
| 357 | 357 |
| 358 bool value_is_quoted_; | 358 bool value_is_quoted_; |
| 359 }; | 359 }; |
| 360 }; | 360 }; |
| 361 | 361 |
| 362 } // namespace net | 362 } // namespace net |
| 363 | 363 |
| 364 #endif // NET_HTTP_HTTP_UTIL_H_ | 364 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |