Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Side by Side Diff: net/http/http_util.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool GetNext(); 215 bool GetNext();
216 216
217 // Iterates through the list of headers, starting with the current position 217 // Iterates through the list of headers, starting with the current position
218 // and looks for the specified header. Note that the name _must_ be 218 // and looks for the specified header. Note that the name _must_ be
219 // lower cased. 219 // lower cased.
220 // If the header was found, the return value will be true and the current 220 // If the header was found, the return value will be true and the current
221 // position points to the header. If the return value is false, the 221 // position points to the header. If the return value is false, the
222 // current position will be at the end of the headers. 222 // current position will be at the end of the headers.
223 bool AdvanceTo(const char* lowercase_name); 223 bool AdvanceTo(const char* lowercase_name);
224 224
225 void Reset() { 225 void Reset() { lines_.Reset(); }
226 lines_.Reset();
227 }
228 226
229 std::string::const_iterator name_begin() const { 227 std::string::const_iterator name_begin() const { return name_begin_; }
230 return name_begin_; 228 std::string::const_iterator name_end() const { return name_end_; }
231 } 229 std::string name() const { return std::string(name_begin_, name_end_); }
232 std::string::const_iterator name_end() const {
233 return name_end_;
234 }
235 std::string name() const {
236 return std::string(name_begin_, name_end_);
237 }
238 230
239 std::string::const_iterator values_begin() const { 231 std::string::const_iterator values_begin() const { return values_begin_; }
240 return values_begin_; 232 std::string::const_iterator values_end() const { return values_end_; }
241 }
242 std::string::const_iterator values_end() const {
243 return values_end_;
244 }
245 std::string values() const { 233 std::string values() const {
246 return std::string(values_begin_, values_end_); 234 return std::string(values_begin_, values_end_);
247 } 235 }
248 236
249 private: 237 private:
250 base::StringTokenizer lines_; 238 base::StringTokenizer lines_;
251 std::string::const_iterator name_begin_; 239 std::string::const_iterator name_begin_;
252 std::string::const_iterator name_end_; 240 std::string::const_iterator name_end_;
253 std::string::const_iterator values_begin_; 241 std::string::const_iterator values_begin_;
254 std::string::const_iterator values_end_; 242 std::string::const_iterator values_end_;
(...skipping 14 matching lines...) Expand all
269 public: 257 public:
270 ValuesIterator(std::string::const_iterator values_begin, 258 ValuesIterator(std::string::const_iterator values_begin,
271 std::string::const_iterator values_end, 259 std::string::const_iterator values_end,
272 char delimiter); 260 char delimiter);
273 ~ValuesIterator(); 261 ~ValuesIterator();
274 262
275 // Advances the iterator to the next value, if any. Returns true if there 263 // Advances the iterator to the next value, if any. Returns true if there
276 // is a next value. Use value* methods to access the resultant value. 264 // is a next value. Use value* methods to access the resultant value.
277 bool GetNext(); 265 bool GetNext();
278 266
279 std::string::const_iterator value_begin() const { 267 std::string::const_iterator value_begin() const { return value_begin_; }
280 return value_begin_; 268 std::string::const_iterator value_end() const { return value_end_; }
281 } 269 std::string value() const { return std::string(value_begin_, value_end_); }
282 std::string::const_iterator value_end() const {
283 return value_end_;
284 }
285 std::string value() const {
286 return std::string(value_begin_, value_end_);
287 }
288 270
289 private: 271 private:
290 base::StringTokenizer values_; 272 base::StringTokenizer values_;
291 std::string::const_iterator value_begin_; 273 std::string::const_iterator value_begin_;
292 std::string::const_iterator value_end_; 274 std::string::const_iterator value_end_;
293 }; 275 };
294 276
295 // Iterates over a delimited sequence of name-value pairs in an HTTP header. 277 // Iterates over a delimited sequence of name-value pairs in an HTTP header.
296 // Each pair consists of a token (the name), an equals sign, and either a 278 // Each pair consists of a token (the name), an equals sign, and either a
297 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside 279 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside
(...skipping 22 matching lines...) Expand all
320 std::string name() const { return std::string(name_begin_, name_end_); } 302 std::string name() const { return std::string(name_begin_, name_end_); }
321 303
322 // The value of the current name-value pair. 304 // The value of the current name-value pair.
323 std::string::const_iterator value_begin() const { 305 std::string::const_iterator value_begin() const {
324 return value_is_quoted_ ? unquoted_value_.begin() : value_begin_; 306 return value_is_quoted_ ? unquoted_value_.begin() : value_begin_;
325 } 307 }
326 std::string::const_iterator value_end() const { 308 std::string::const_iterator value_end() const {
327 return value_is_quoted_ ? unquoted_value_.end() : value_end_; 309 return value_is_quoted_ ? unquoted_value_.end() : value_end_;
328 } 310 }
329 std::string value() const { 311 std::string value() const {
330 return value_is_quoted_ ? unquoted_value_ : std::string(value_begin_, 312 return value_is_quoted_ ? unquoted_value_
331 value_end_); 313 : std::string(value_begin_, value_end_);
332 } 314 }
333 315
334 // The value before unquoting (if any). 316 // The value before unquoting (if any).
335 std::string raw_value() const { return std::string(value_begin_, 317 std::string raw_value() const {
336 value_end_); } 318 return std::string(value_begin_, value_end_);
319 }
337 320
338 private: 321 private:
339 HttpUtil::ValuesIterator props_; 322 HttpUtil::ValuesIterator props_;
340 bool valid_; 323 bool valid_;
341 324
342 std::string::const_iterator name_begin_; 325 std::string::const_iterator name_begin_;
343 std::string::const_iterator name_end_; 326 std::string::const_iterator name_end_;
344 327
345 std::string::const_iterator value_begin_; 328 std::string::const_iterator value_begin_;
346 std::string::const_iterator value_end_; 329 std::string::const_iterator value_end_;
347 330
348 // Do not store iterators into this string. The NameValuePairsIterator 331 // Do not store iterators into this string. The NameValuePairsIterator
349 // is copyable/assignable, and if copied the copy's iterators would point 332 // is copyable/assignable, and if copied the copy's iterators would point
350 // into the original's unquoted_value_ member. 333 // into the original's unquoted_value_ member.
351 std::string unquoted_value_; 334 std::string unquoted_value_;
352 335
353 bool value_is_quoted_; 336 bool value_is_quoted_;
354 }; 337 };
355 }; 338 };
356 339
357 } // namespace net 340 } // namespace net
358 341
359 #endif // NET_HTTP_HTTP_UTIL_H_ 342 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698