Chromium Code Reviews| Index: net/cookies/cookie_util.h |
| diff --git a/net/cookies/cookie_util.h b/net/cookies/cookie_util.h |
| index aaaf27d41aa7f4c992d9c5a0b1840706dc9831c7..e0e044ddba0b75d7deedfdb441d06d74dc6485ca 100644 |
| --- a/net/cookies/cookie_util.h |
| +++ b/net/cookies/cookie_util.h |
| @@ -6,7 +6,10 @@ |
| #define NET_COOKIES_COOKIE_UTIL_H_ |
| #include <string> |
| +#include <utility> |
| +#include <vector> |
| +#include "base/strings/string_piece.h" |
| #include "base/time/time.h" |
| #include "net/base/net_export.h" |
| @@ -40,7 +43,24 @@ NET_EXPORT base::Time ParseCookieTime(const std::string& time_string); |
| // Convenience for converting a cookie origin (domain and https pair) to a URL. |
| NET_EXPORT GURL CookieOriginToURL(const std::string& domain, bool is_https); |
| -} // namspace cookie_util |
| +// A ParsedRequestCookie consists of the key and value of the cookie. |
| +typedef std::pair<base::StringPiece, base::StringPiece> ParsedRequestCookie; |
| +typedef std::vector<ParsedRequestCookie> ParsedRequestCookies; |
| + |
| +// Assumes that |header_value| is the cookie header value of a HTTP Request |
| +// following the cookie-string schema of RFC 6265, section 4.2.1, and returns |
| +// cookie name/value pairs. If cookie values are presented in double quotes, |
| +// these will appear in |parsed_cookies| as well. Assumes that the cookie |
| +// header is written by Chromium and therefore well-formed. |
| +NET_EXPORT void ParseRequestCookieLine(const std::string& header_value, |
|
erikwright (departed)
2014/07/09 15:36:23
Please add tests for these methods.
I wish that "
Marc Treib
2014/07/10 09:03:36
I've added some tests (which actually uncovered a
|
| + ParsedRequestCookies* parsed_cookies); |
| + |
| +// Writes all cookies of |parsed_cookies| into a HTTP Request header value |
| +// that belongs to the "Cookie" header. |
| +NET_EXPORT std::string SerializeRequestCookieLine( |
|
erikwright (departed)
2014/07/09 15:36:23
This method requires that |parsed_cookies| be appr
Marc Treib
2014/07/10 09:03:36
Done.
|
| + const ParsedRequestCookies& parsed_cookies); |
| + |
| +} // namespace cookie_util |
| } // namespace net |
| #endif // NET_COOKIES_COOKIE_UTIL_H_ |