OLD | NEW |
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_COOKIES_COOKIE_UTIL_H_ | 5 #ifndef NET_COOKIES_COOKIE_UTIL_H_ |
6 #define NET_COOKIES_COOKIE_UTIL_H_ | 6 #define NET_COOKIES_COOKIE_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 19 matching lines...) Expand all Loading... |
30 // -host cookie domain (ex: "google.com") | 30 // -host cookie domain (ex: "google.com") |
31 // -domain cookie domain (ex: ".google.com") | 31 // -domain cookie domain (ex: ".google.com") |
32 NET_EXPORT bool GetCookieDomainWithString(const GURL& url, | 32 NET_EXPORT bool GetCookieDomainWithString(const GURL& url, |
33 const std::string& domain_string, | 33 const std::string& domain_string, |
34 std::string* result); | 34 std::string* result); |
35 | 35 |
36 // Returns true if a domain string represents a host-only cookie, | 36 // Returns true if a domain string represents a host-only cookie, |
37 // i.e. it doesn't begin with a leading '.' character. | 37 // i.e. it doesn't begin with a leading '.' character. |
38 NET_EXPORT bool DomainIsHostOnly(const std::string& domain_string); | 38 NET_EXPORT bool DomainIsHostOnly(const std::string& domain_string); |
39 | 39 |
40 // Parses the string with the cookie expiration time (very forgivingly). | 40 // Parses the string with the cookie time (very forgivingly). |
41 // Returns the "null" time on failure. | 41 NET_EXPORT base::Time ParseCookieTime(const std::string& time_string); |
42 // | |
43 // If the expiration date is either too small or too large (there are | |
44 // platform-specific limits for allowed date ranges), then it will be clipped | |
45 // to the min/max time Time::FromUTCExploded() can return on the current | |
46 // platform, | |
47 // rather than failing. In particular: | |
48 // | |
49 // On non-Mac 32-bit POSIX, times will currently be clamped between 1970 and | |
50 // 2038. | |
51 // On Windows, times will currently be clamped between year 1601 and 30827. | |
52 NET_EXPORT base::Time ParseCookieExpirationTime(const std::string& time_string); | |
53 | 42 |
54 // Convenience for converting a cookie origin (domain and https pair) to a URL. | 43 // Convenience for converting a cookie origin (domain and https pair) to a URL. |
55 NET_EXPORT GURL CookieOriginToURL(const std::string& domain, bool is_https); | 44 NET_EXPORT GURL CookieOriginToURL(const std::string& domain, bool is_https); |
56 | 45 |
57 // A ParsedRequestCookie consists of the key and value of the cookie. | 46 // A ParsedRequestCookie consists of the key and value of the cookie. |
58 typedef std::pair<base::StringPiece, base::StringPiece> ParsedRequestCookie; | 47 typedef std::pair<base::StringPiece, base::StringPiece> ParsedRequestCookie; |
59 typedef std::vector<ParsedRequestCookie> ParsedRequestCookies; | 48 typedef std::vector<ParsedRequestCookie> ParsedRequestCookies; |
60 | 49 |
61 // Assumes that |header_value| is the cookie header value of a HTTP Request | 50 // Assumes that |header_value| is the cookie header value of a HTTP Request |
62 // following the cookie-string schema of RFC 6265, section 4.2.1, and returns | 51 // following the cookie-string schema of RFC 6265, section 4.2.1, and returns |
63 // cookie name/value pairs. If cookie values are presented in double quotes, | 52 // cookie name/value pairs. If cookie values are presented in double quotes, |
64 // these will appear in |parsed_cookies| as well. Assumes that the cookie | 53 // these will appear in |parsed_cookies| as well. Assumes that the cookie |
65 // header is written by Chromium and therefore well-formed. | 54 // header is written by Chromium and therefore well-formed. |
66 NET_EXPORT void ParseRequestCookieLine(const std::string& header_value, | 55 NET_EXPORT void ParseRequestCookieLine(const std::string& header_value, |
67 ParsedRequestCookies* parsed_cookies); | 56 ParsedRequestCookies* parsed_cookies); |
68 | 57 |
69 // Writes all cookies of |parsed_cookies| into a HTTP Request header value | 58 // Writes all cookies of |parsed_cookies| into a HTTP Request header value |
70 // that belongs to the "Cookie" header. The entries of |parsed_cookies| must | 59 // that belongs to the "Cookie" header. The entries of |parsed_cookies| must |
71 // already be appropriately escaped. | 60 // already be appropriately escaped. |
72 NET_EXPORT std::string SerializeRequestCookieLine( | 61 NET_EXPORT std::string SerializeRequestCookieLine( |
73 const ParsedRequestCookies& parsed_cookies); | 62 const ParsedRequestCookies& parsed_cookies); |
74 | 63 |
75 } // namespace cookie_util | 64 } // namespace cookie_util |
76 } // namespace net | 65 } // namespace net |
77 | 66 |
78 #endif // NET_COOKIES_COOKIE_UTIL_H_ | 67 #endif // NET_COOKIES_COOKIE_UTIL_H_ |
OLD | NEW |