| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 // Used to iterate over the name/value pairs of HTTP headers. To iterate | 161 // Used to iterate over the name/value pairs of HTTP headers. To iterate |
| 162 // over the values in a multi-value header, use ValuesIterator. | 162 // over the values in a multi-value header, use ValuesIterator. |
| 163 // See AssembleRawHeaders for joining line continuations (this iterator | 163 // See AssembleRawHeaders for joining line continuations (this iterator |
| 164 // does not expect any). | 164 // does not expect any). |
| 165 class HeadersIterator { | 165 class HeadersIterator { |
| 166 public: | 166 public: |
| 167 HeadersIterator(std::string::const_iterator headers_begin, | 167 HeadersIterator(std::string::const_iterator headers_begin, |
| 168 std::string::const_iterator headers_end, | 168 std::string::const_iterator headers_end, |
| 169 const std::string& line_delimiter); | 169 const std::string& line_delimiter); |
| 170 ~HeadersIterator(); |
| 170 | 171 |
| 171 // Advances the iterator to the next header, if any. Returns true if there | 172 // Advances the iterator to the next header, if any. Returns true if there |
| 172 // is a next header. Use name* and values* methods to access the resultant | 173 // is a next header. Use name* and values* methods to access the resultant |
| 173 // header name and values. | 174 // header name and values. |
| 174 bool GetNext(); | 175 bool GetNext(); |
| 175 | 176 |
| 176 // Iterates through the list of headers, starting with the current position | 177 // Iterates through the list of headers, starting with the current position |
| 177 // and looks for the specified header. Note that the name _must_ be | 178 // and looks for the specified header. Note that the name _must_ be |
| 178 // lower cased. | 179 // lower cased. |
| 179 // If the header was found, the return value will be true and the current | 180 // If the header was found, the return value will be true and the current |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // non-coalescing (see IsNonCoalescingHeader). | 223 // non-coalescing (see IsNonCoalescingHeader). |
| 223 // | 224 // |
| 224 // This iterator is careful to skip over delimiters found inside an HTTP | 225 // This iterator is careful to skip over delimiters found inside an HTTP |
| 225 // quoted string. | 226 // quoted string. |
| 226 // | 227 // |
| 227 class ValuesIterator { | 228 class ValuesIterator { |
| 228 public: | 229 public: |
| 229 ValuesIterator(std::string::const_iterator values_begin, | 230 ValuesIterator(std::string::const_iterator values_begin, |
| 230 std::string::const_iterator values_end, | 231 std::string::const_iterator values_end, |
| 231 char delimiter); | 232 char delimiter); |
| 233 ~ValuesIterator(); |
| 232 | 234 |
| 233 // Advances the iterator to the next value, if any. Returns true if there | 235 // Advances the iterator to the next value, if any. Returns true if there |
| 234 // is a next value. Use value* methods to access the resultant value. | 236 // is a next value. Use value* methods to access the resultant value. |
| 235 bool GetNext(); | 237 bool GetNext(); |
| 236 | 238 |
| 237 std::string::const_iterator value_begin() const { | 239 std::string::const_iterator value_begin() const { |
| 238 return value_begin_; | 240 return value_begin_; |
| 239 } | 241 } |
| 240 std::string::const_iterator value_end() const { | 242 std::string::const_iterator value_end() const { |
| 241 return value_end_; | 243 return value_end_; |
| 242 } | 244 } |
| 243 std::string value() const { | 245 std::string value() const { |
| 244 return std::string(value_begin_, value_end_); | 246 return std::string(value_begin_, value_end_); |
| 245 } | 247 } |
| 246 | 248 |
| 247 private: | 249 private: |
| 248 StringTokenizer values_; | 250 StringTokenizer values_; |
| 249 std::string::const_iterator value_begin_; | 251 std::string::const_iterator value_begin_; |
| 250 std::string::const_iterator value_end_; | 252 std::string::const_iterator value_end_; |
| 251 }; | 253 }; |
| 252 }; | 254 }; |
| 253 | 255 |
| 254 } // namespace net | 256 } // namespace net |
| 255 | 257 |
| 256 #endif // NET_HTTP_HTTP_UTIL_H_ | 258 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |