HTTPCookie
-
class HTTPCookie
A cookie sent from an HTTP server to be stored on the client and returned when the path and/or domain matches.
Inheritance diagram
-
enum SameSite
-
enumerator SS_unspecified = 0
-
enumerator SS_lax = 1
-
enumerator SS_strict = 2
-
enumerator SS_none = 3
-
enumerator SS_unspecified = 0
-
HTTPCookie(void) = default
-
explicit HTTPCookie(std::string const &name, std::string const &path, std::string const &domain)
-
HTTPCookie(HTTPCookie const&) = default
Constructs a cookie according to the indicated string, presumably the tag of a Set-Cookie header. There is no way to detect a formatting error in the string with this constructor.
Constructs a cookie with the indicated name, path, and domain values, but no other data. This is most useful for looking up an existing cookie in the
HTTPClient
.
-
void clear_expires(void)
Removes the expiration date on the cookie.
-
std::string const &get_domain(void) const
-
HTTPDate get_expires(void) const
Returns the expiration date of the cookie if it is set, or an invalid date if it is not.
-
std::string const &get_name(void) const
Returns the name of the cookie. This is the key value specified by the server.
-
std::string const &get_path(void) const
Returns the prefix of the URL paths on the server for which this cookie will be sent.
-
bool get_secure(void) const
Returns true if the server has indicated this is a “secure” cookie which should only be sent over an HTTPS channel.
-
std::string const &get_value(void) const
Returns the value of the cookie. This is the arbitrary string associated with the cookie’s name, as specified by the server.
-
bool has_expires(void) const
Returns true if the cookie has an expiration date, false otherwise.
-
bool is_expired(HTTPDate const &now = HTTPDate::now()) const
Returns true if the cookie’s expiration date is before the indicated date, false otherwise.
-
bool matches_url(URLSpec const &url) const
Returns true if the cookie is appropriate to send with the indicated URL request, false otherwise.
-
void output(std::ostream &out) const
-
bool parse_set_cookie(std::string const &format, URLSpec const &url)
Separates out the parameter/value pairs of the Set-Cookie header and assigns the values of the cookie appropriate. Returns true if the header is parsed correctly, false if something is not understood.
-
void set_domain(std::string const &domain)
-
void set_name(std::string const &name)
-
void set_path(std::string const &path)
-
void set_samesite(HTTPCookie::SameSite samesite)
-
void set_secure(bool flag)
-
void set_value(std::string const &value)
-
void update_from(HTTPCookie const &other)
Assuming the operator < method, above, has already evaluated these two cookies as equal, then assign the remaining values (value, expiration date, secure flag) from the indicated cookie. This is guaranteed not to change the ordering of the cookie in a set, and so can be used to update an existing cookie within a set with new values.
-
enum SameSite