Ark Server API (ASE) - Wiki
|
#include <HTTPCookie.h>
Public Types | |
enum | SameSite { SAME_SITE_NOT_SPECIFIED , SAME_SITE_NONE , SAME_SITE_LAX , SAME_SITE_STRICT } |
Public Member Functions | |
HTTPCookie () | |
HTTPCookie (const std::string &name) | |
Creates an empty HTTPCookie. | |
HTTPCookie (const NameValueCollection &nvc) | |
HTTPCookie (const std::string &name, const std::string &value) | |
Creates a cookie from the given NameValueCollection. | |
HTTPCookie (const HTTPCookie &cookie) | |
~HTTPCookie () | |
Creates the HTTPCookie by copying another one. | |
HTTPCookie & | operator= (const HTTPCookie &cookie) |
Destroys the HTTPCookie. | |
void | setVersion (int version) |
Assigns a cookie. | |
int | getVersion () const |
void | setName (const std::string &name) |
const std::string & | getName () const |
Sets the name of the cookie. | |
void | setValue (const std::string &value) |
Returns the name of the cookie. | |
const std::string & | getValue () const |
void | setComment (const std::string &comment) |
Returns the value of the cookie. | |
const std::string & | getComment () const |
void | setDomain (const std::string &domain) |
Returns the comment for the cookie. | |
const std::string & | getDomain () const |
Sets the domain for the cookie. | |
void | setPath (const std::string &path) |
Returns the domain for the cookie. | |
void | setPriority (const std::string &priority) |
Sets the path for the cookie. | |
const std::string & | getPath () const |
Sets the priority for the cookie. | |
const std::string & | getPriority () const |
Returns the path for the cookie. | |
void | setSecure (bool secure) |
Returns the priority for the cookie. | |
bool | getSecure () const |
void | setMaxAge (int maxAge) |
int | getMaxAge () const |
void | setHttpOnly (bool flag=true) |
bool | getHttpOnly () const |
Sets the HttpOnly flag for the cookie. | |
void | setSameSite (SameSite value) |
Returns true iff the cookie's HttpOnly flag is set. | |
SameSite | getSameSite () const |
Sets the cookie's SameSite attribute. | |
std::string | toString () const |
Returns the cookie's SameSite attribute. | |
Static Public Member Functions | |
static std::string | escape (const std::string &str) |
static std::string | unescape (const std::string &str) |
Private Attributes | |
int | _version |
std::string | _name |
std::string | _value |
std::string | _comment |
std::string | _domain |
std::string | _path |
std::string | _priority |
bool | _secure |
int | _maxAge |
bool | _httpOnly |
SameSite | _sameSite |
This class represents a HTTP Cookie.
A cookie is a small amount of information sent by a Web server to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management. A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. This class supports both the Version 0 (by Netscape) and Version 1 (by RFC 2109) cookie specifications. By default, cookies are created using Version 0 to ensure the best interoperability.
Definition at line 31 of file HTTPCookie.h.
Enumerator | |
---|---|
SAME_SITE_NOT_SPECIFIED | |
SAME_SITE_NONE | |
SAME_SITE_LAX | |
SAME_SITE_STRICT |
Definition at line 48 of file HTTPCookie.h.
Poco::Net::HTTPCookie::HTTPCookie | ( | ) |
|
explicit |
Creates an empty HTTPCookie.
|
explicit |
Creates a cookie with the given name. The cookie never expires.
Poco::Net::HTTPCookie::HTTPCookie | ( | const std::string & | name, |
const std::string & | value ) |
Creates a cookie from the given NameValueCollection.
Poco::Net::HTTPCookie::HTTPCookie | ( | const HTTPCookie & | cookie | ) |
Creates a cookie with the given name and value. The cookie never expires.
Note: If value contains whitespace or non-alphanumeric characters, the value should be escaped by calling escape() before passing it to the constructor.
Poco::Net::HTTPCookie::~HTTPCookie | ( | ) |
Creates the HTTPCookie by copying another one.
|
static |
Returns a string representation of the cookie, suitable for use in a Set-Cookie header.
|
inline |
Sets the comment for the cookie.
Comments are only supported for version 1 cookies.
Definition at line 242 of file HTTPCookie.h.
|
inline |
Sets the domain for the cookie.
Definition at line 248 of file HTTPCookie.h.
|
inline |
Sets the HttpOnly flag for the cookie.
Definition at line 278 of file HTTPCookie.h.
|
inline |
Sets the maximum age in seconds for the cookie.
A value of -1 (default) causes the cookie to become a session cookie, which will be deleted when the browser window is closed.
A value of 0 deletes the cookie on the client.
Definition at line 272 of file HTTPCookie.h.
|
inline |
Sets the name of the cookie.
Definition at line 230 of file HTTPCookie.h.
|
inline |
Sets the priority for the cookie.
Definition at line 254 of file HTTPCookie.h.
|
inline |
Returns the path for the cookie.
Definition at line 260 of file HTTPCookie.h.
|
inline |
Sets the cookie's SameSite attribute.
Definition at line 284 of file HTTPCookie.h.
|
inline |
Sets the value of the secure flag for the cookie.
Definition at line 266 of file HTTPCookie.h.
|
inline |
Sets the value of the cookie.
According to the cookie specification, the size of the value should not exceed 4 Kbytes.
Note: If value contains whitespace or non-alphanumeric characters, the value should be escaped by calling escape() prior to passing it to setName().
Definition at line 236 of file HTTPCookie.h.
|
inline |
Sets the version of the cookie.
Version must be either 0 (denoting a Netscape cookie) or 1 (denoting a RFC 2109 cookie).
Definition at line 224 of file HTTPCookie.h.
HTTPCookie & Poco::Net::HTTPCookie::operator= | ( | const HTTPCookie & | cookie | ) |
Destroys the HTTPCookie.
void Poco::Net::HTTPCookie::setComment | ( | const std::string & | comment | ) |
Returns the value of the cookie.
void Poco::Net::HTTPCookie::setDomain | ( | const std::string & | domain | ) |
Returns the comment for the cookie.
void Poco::Net::HTTPCookie::setHttpOnly | ( | bool | flag = true | ) |
Returns the maximum age in seconds for the cookie.
void Poco::Net::HTTPCookie::setMaxAge | ( | int | maxAge | ) |
Returns the value of the secure flag for the cookie.
void Poco::Net::HTTPCookie::setName | ( | const std::string & | name | ) |
Returns the version of the cookie, which is either 0 or 1.
void Poco::Net::HTTPCookie::setPath | ( | const std::string & | path | ) |
Returns the domain for the cookie.
void Poco::Net::HTTPCookie::setPriority | ( | const std::string & | priority | ) |
Sets the path for the cookie.
void Poco::Net::HTTPCookie::setSameSite | ( | SameSite | value | ) |
Returns true iff the cookie's HttpOnly flag is set.
void Poco::Net::HTTPCookie::setSecure | ( | bool | secure | ) |
Returns the priority for the cookie.
void Poco::Net::HTTPCookie::setValue | ( | const std::string & | value | ) |
Returns the name of the cookie.
void Poco::Net::HTTPCookie::setVersion | ( | int | version | ) |
Assigns a cookie.
std::string Poco::Net::HTTPCookie::toString | ( | ) | const |
Returns the cookie's SameSite attribute.
|
static |
Escapes the given string by replacing all non-alphanumeric characters with escape sequences in the form xx, where xx is the hexadecimal character code.
The following characters will be replaced with escape sequences:
|
private |
Definition at line 210 of file HTTPCookie.h.
|
private |
Definition at line 211 of file HTTPCookie.h.
|
private |
Definition at line 216 of file HTTPCookie.h.
|
private |
Definition at line 215 of file HTTPCookie.h.
|
private |
Definition at line 208 of file HTTPCookie.h.
|
private |
Definition at line 212 of file HTTPCookie.h.
|
private |
Definition at line 213 of file HTTPCookie.h.
|
private |
Definition at line 217 of file HTTPCookie.h.
|
private |
Definition at line 214 of file HTTPCookie.h.
|
private |
Definition at line 209 of file HTTPCookie.h.
|
private |
Unescapes the given string by replacing all escape sequences in the form xx with the respective characters.
Definition at line 207 of file HTTPCookie.h.