NCBI C++ ToolKit
|
Search Toolkit Book for CHttpCookie
#include <corelib/ncbi_cookies.hpp>
Public Types | |
enum | ECookieFormat { eHTTPResponse , eHTTPRequest } |
Whether the cookie is sent as a part of HTTP request or HTTP response. More... | |
enum | EFieldType { eField_Name , eField_Value , eField_Domain , eField_Path , eField_Extension , eField_Other } |
Cookie field selector. More... | |
Public Member Functions | |
CHttpCookie (void) | |
Create an empty cookie. More... | |
CHttpCookie (const CTempString &name, const CTempString &value, const CTempString &domain=kEmptyStr, const CTempString &path=kEmptyStr) | |
Create a cookie with the given attributes. More... | |
const string & | GetName (void) const |
Get cookie's name. No encoding/decoding is performed. More... | |
const string & | GetValue (void) const |
Get cookie's value. No encoding/decoding is performed. More... | |
const string & | GetDomain (void) const |
Get domain. More... | |
bool | GetHostOnly (void) const |
Get host-only flag. More... | |
const string & | GetPath (void) const |
Get path. More... | |
string | GetExpirationStr (void) const |
Get string representaion of expiration time (dd-Mon-yyyy hh:mm:ss GMT) or empty string if expiration is not set. More... | |
const CTime & | GetExpirationTime (void) const |
The returned CTime may be empty if expiration date is not set. More... | |
bool | GetSecure (void) const |
Get secure flag. More... | |
bool | GetHttpOnly (void) const |
Get HTTP-only flag. More... | |
const string & | GetExtension (void) const |
Get any unparsed attributes merged into a single line using semicolon separators. More... | |
void | SetName (const CTempString &name) |
Set cookie's name. More... | |
void | SetValue (const CTempString &value) |
Set cookie's value. More... | |
void | SetDomain (const CTempString &domain) |
Set cookie's domain. More... | |
void | SetHostOnly (bool host_only) |
Set host-only flag. More... | |
void | SetPath (const CTempString &path) |
Set cookie's path. More... | |
void | SetExpirationTime (const CTime &exp_time) |
Set expiration time, must be a GMT one. More... | |
void | SetSecure (bool secure) |
Set secure flag. More... | |
void | SetHttpOnly (bool http_only) |
Set HTTP-only flag. More... | |
void | SetExtension (const CTempString &extension) |
Any additional attributes (multiple attributes should be separated with semicolon). More... | |
bool | IsExpired (void) const |
Check if the cookie is currently expired. More... | |
bool | IsExpired (const CTime &now) const |
Check if the cookie has expired by "now". More... | |
bool | Validate (void) const |
Check if name, value, domain and path of the cookie are valid. More... | |
string | AsString (ECookieFormat format) const |
Compose string from the cookie. More... | |
bool | Parse (const CTempString &str) |
Read cookie from the string. More... | |
bool | operator< (const CHttpCookie &cookie) const |
Compare two cookies: More... | |
bool | operator== (const CHttpCookie &cookie) const |
Compare two cookies. More... | |
bool | Match (const CUrl &url) const |
Check if the cookie matches domain, path and scheme of the URL. More... | |
bool | MatchDomain (const string &host) const |
Helper method for string matching. More... | |
bool | MatchPath (const string &path) const |
'path' matches if it starts with 'cookie_path' and the last matching char or the first non-matching char is '/'. More... | |
void | Reset (void) |
Reset value and all attributes, keep just the name. More... | |
Static Public Member Functions | |
static bool | IsValidValue (const string &value, EFieldType field, string *err_msg=NULL) |
Check if the value can be safely used for the selected field. More... | |
Private Member Functions | |
void | x_Validate (const string &value, EFieldType field) const |
Static Private Member Functions | |
static int | sx_Compare (const CHttpCookie &c1, const CHttpCookie &c2) |
Private Attributes | |
string | m_Name |
string | m_Value |
string | m_Domain |
string | m_Path |
CTime | m_Expires |
bool | m_Secure |
bool | m_HttpOnly |
string | m_Extension |
CTime | m_Created |
CTime | m_Accessed |
bool | m_HostOnly |