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

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

Issue 1249823002: Revert of Parse HPKP report-uri and persist in TransportSecurityPersister (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « net/http/http_security_headers_unittest.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11 matching lines...) Expand all
22 22
23 namespace net { 23 namespace net {
24 24
25 class NET_EXPORT HttpUtil { 25 class NET_EXPORT HttpUtil {
26 public: 26 public:
27 // Returns the absolute URL, to be used for the http request. This url is 27 // Returns the absolute URL, to be used for the http request. This url is
28 // made up of the protocol, host, [port], path, [query]. Everything else 28 // made up of the protocol, host, [port], path, [query]. Everything else
29 // is stripped (username, password, reference). 29 // is stripped (username, password, reference).
30 static std::string SpecForRequest(const GURL& url); 30 static std::string SpecForRequest(const GURL& url);
31 31
32 // Locates the next occurance of delimiter in line, skipping over quoted
33 // strings (e.g., commas will not be treated as delimiters if they appear
34 // within a quoted string). Returns the offset of the found delimiter or
35 // line.size() if no delimiter was found.
36 static size_t FindDelimiter(const std::string& line,
37 size_t search_start,
38 char delimiter);
39
32 // Parses the value of a Content-Type header. The resulting mime_type and 40 // Parses the value of a Content-Type header. The resulting mime_type and
33 // charset values are normalized to lowercase. The mime_type and charset 41 // charset values are normalized to lowercase. The mime_type and charset
34 // output values are only modified if the content_type_str contains a mime 42 // output values are only modified if the content_type_str contains a mime
35 // type and charset value, respectively. The boundary output value is 43 // type and charset value, respectively. The boundary output value is
36 // optional and will be assigned the (quoted) value of the boundary 44 // optional and will be assigned the (quoted) value of the boundary
37 // paramter, if any. 45 // paramter, if any.
38 static void ParseContentType(const std::string& content_type_str, 46 static void ParseContentType(const std::string& content_type_str,
39 std::string* mime_type, 47 std::string* mime_type,
40 std::string* charset, 48 std::string* charset,
41 bool* had_charset, 49 bool* had_charset,
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 316
309 // Iterates over a delimited sequence of name-value pairs in an HTTP header. 317 // Iterates over a delimited sequence of name-value pairs in an HTTP header.
310 // Each pair consists of a token (the name), an equals sign, and either a 318 // Each pair consists of a token (the name), an equals sign, and either a
311 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside 319 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside
312 // of and between names, values, and delimiters. 320 // of and between names, values, and delimiters.
313 // 321 //
314 // String iterators returned from this class' methods may be invalidated upon 322 // String iterators returned from this class' methods may be invalidated upon
315 // calls to GetNext() or after the NameValuePairsIterator is destroyed. 323 // calls to GetNext() or after the NameValuePairsIterator is destroyed.
316 class NET_EXPORT NameValuePairsIterator { 324 class NET_EXPORT NameValuePairsIterator {
317 public: 325 public:
318 // Whether or not values are optional. VALUES_OPTIONAL allows
319 // e.g. name1=value1;name2;name3=value3, whereas VALUES_NOT_OPTIONAL
320 // will treat it as a parse error because name2 does not have a
321 // corresponding equals sign.
322 enum OptionalValues { VALUES_OPTIONAL, VALUES_NOT_OPTIONAL };
323
324 NameValuePairsIterator(std::string::const_iterator begin,
325 std::string::const_iterator end,
326 char delimiter,
327 OptionalValues optional_values);
328
329 // Treats values as not optional by default (VALUES_NOT_OPTIONAL).
330 NameValuePairsIterator(std::string::const_iterator begin, 326 NameValuePairsIterator(std::string::const_iterator begin,
331 std::string::const_iterator end, 327 std::string::const_iterator end,
332 char delimiter); 328 char delimiter);
333
334 ~NameValuePairsIterator(); 329 ~NameValuePairsIterator();
335 330
336 // Advances the iterator to the next pair, if any. Returns true if there 331 // Advances the iterator to the next pair, if any. Returns true if there
337 // is a next pair. Use name* and value* methods to access the resultant 332 // is a next pair. Use name* and value* methods to access the resultant
338 // value. 333 // value.
339 bool GetNext(); 334 bool GetNext();
340 335
341 // Returns false if there was a parse error. 336 // Returns false if there was a parse error.
342 bool valid() const { return valid_; } 337 bool valid() const { return valid_; }
343 338
344 // The name of the current name-value pair. 339 // The name of the current name-value pair.
345 std::string::const_iterator name_begin() const { return name_begin_; } 340 std::string::const_iterator name_begin() const { return name_begin_; }
346 std::string::const_iterator name_end() const { return name_end_; } 341 std::string::const_iterator name_end() const { return name_end_; }
347 std::string name() const { return std::string(name_begin_, name_end_); } 342 std::string name() const { return std::string(name_begin_, name_end_); }
348 343
349 // The value of the current name-value pair. 344 // The value of the current name-value pair.
350 std::string::const_iterator value_begin() const { 345 std::string::const_iterator value_begin() const {
351 return value_is_quoted_ ? unquoted_value_.begin() : value_begin_; 346 return value_is_quoted_ ? unquoted_value_.begin() : value_begin_;
352 } 347 }
353 std::string::const_iterator value_end() const { 348 std::string::const_iterator value_end() const {
354 return value_is_quoted_ ? unquoted_value_.end() : value_end_; 349 return value_is_quoted_ ? unquoted_value_.end() : value_end_;
355 } 350 }
356 std::string value() const { 351 std::string value() const {
357 return value_is_quoted_ ? unquoted_value_ : std::string(value_begin_, 352 return value_is_quoted_ ? unquoted_value_ : std::string(value_begin_,
358 value_end_); 353 value_end_);
359 } 354 }
360 355
361 bool value_is_quoted() const { return value_is_quoted_; }
362
363 // The value before unquoting (if any). 356 // The value before unquoting (if any).
364 std::string raw_value() const { return std::string(value_begin_, 357 std::string raw_value() const { return std::string(value_begin_,
365 value_end_); } 358 value_end_); }
366 359
367 private: 360 private:
368 HttpUtil::ValuesIterator props_; 361 HttpUtil::ValuesIterator props_;
369 bool valid_; 362 bool valid_;
370 363
371 std::string::const_iterator name_begin_; 364 std::string::const_iterator name_begin_;
372 std::string::const_iterator name_end_; 365 std::string::const_iterator name_end_;
373 366
374 std::string::const_iterator value_begin_; 367 std::string::const_iterator value_begin_;
375 std::string::const_iterator value_end_; 368 std::string::const_iterator value_end_;
376 369
377 // Do not store iterators into this string. The NameValuePairsIterator 370 // Do not store iterators into this string. The NameValuePairsIterator
378 // is copyable/assignable, and if copied the copy's iterators would point 371 // is copyable/assignable, and if copied the copy's iterators would point
379 // into the original's unquoted_value_ member. 372 // into the original's unquoted_value_ member.
380 std::string unquoted_value_; 373 std::string unquoted_value_;
381 374
382 bool value_is_quoted_; 375 bool value_is_quoted_;
383
384 // True if values are required for each name/value pair; false if a
385 // name is permitted to appear without a corresponding value.
386 bool values_optional_;
387 }; 376 };
388 }; 377 };
389 378
390 } // namespace net 379 } // namespace net
391 380
392 #endif // NET_HTTP_HTTP_UTIL_H_ 381 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW
« no previous file with comments | « net/http/http_security_headers_unittest.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698