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

Side by Side Diff: components/link_header_util/link_header_util.h

Issue 1811163002: Share link header parsing code between blink and content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base-optional
Patch Set: rebase Created 4 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
« no previous file with comments | « components/link_header_util/OWNERS ('k') | components/link_header_util/link_header_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
(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_
OLDNEW
« no previous file with comments | « components/link_header_util/OWNERS ('k') | components/link_header_util/link_header_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698