OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_LINK_HEADER_UTIL_LINK_HEADER_UTIL_H_ |
| 6 #define COMPONENTS_LINK_HEADER_UTIL_LINK_HEADER_UTIL_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <unordered_map> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "base/optional.h" |
| 14 |
| 15 namespace link_header_util { |
| 16 |
| 17 using StringIteratorPair = |
| 18 std::pair<std::string::const_iterator, std::string::const_iterator>; |
| 19 |
| 20 // Split a Link: header in its individual values. A single Link: header can |
| 21 // contain multiple values, which are comma separated. This method splits the |
| 22 // entire string into iterator pairs for the individual link values. |
| 23 // This is very similar to what net::HttpUtil::ValuesIterator does, except it |
| 24 // takes the special syntax of <> enclosed URLs into account. |
| 25 std::vector<StringIteratorPair> SplitLinkHeader(const std::string& header); |
| 26 |
| 27 // Parse an individual link header in its URL and parameters. |begin| and |end| |
| 28 // indicate the string to parse. If it is succesfully parsed as a link header |
| 29 // value this method returns true, sets |url| to the URL part of the link header |
| 30 // value and adds the parameters from the link header value to |params|. |
| 31 // If any error occurs parsing, this returns false (but might have also modified |
| 32 // |url| and/or |params|). |
| 33 bool ParseLinkHeaderValue( |
| 34 std::string::const_iterator begin, |
| 35 std::string::const_iterator end, |
| 36 std::string* url, |
| 37 std::unordered_map<std::string, base::Optional<std::string>>* params); |
| 38 |
| 39 } // namespace link_header_util |
| 40 |
| 41 #endif // COMPONENTS_LINK_HEADER_UTIL_LINK_HEADER_UTIL_H_ |
OLD | NEW |