NCBI C++ ToolKit
Classes | Typedefs | Enumerations | Enumerator | Functions | Variables | Friends
HTTPClient

Classes

class  CHttpCookie
 CHttpCookie:: More...
 
class  CHttpCookies
 
struct  CHttpCookies::SDomainLess
 
class  CHttpCookie_CI
 CHttpCookie_CI:: More...
 
class  CHttpCookieException
 CHttpCookieException –. More...
 

Typedefs

typedef CHttpCookie_CI CHttpCookies::const_iterator
 Allow to use cookies with macros like ITERATE. More...
 
typedef list< CHttpCookieCHttpCookies::TCookieList
 
typedef map< string, TCookieList, SDomainLessCHttpCookies::TCookieMap
 
typedef CHttpCookies::TCookieList CHttpCookie_CI::TCookieList
 
typedef TCookieList::const_iterator CHttpCookie_CI::TList_CI
 
typedef CHttpCookies::TCookieMap CHttpCookie_CI::TCookieMap
 
typedef TCookieMap::const_iterator CHttpCookie_CI::TMap_CI
 

Enumerations

enum  CHttpCookie::ECookieFormat { CHttpCookie::eHTTPResponse , CHttpCookie::eHTTPRequest }
 Whether the cookie is sent as a part of HTTP request or HTTP response. More...
 
enum  CHttpCookie::EFieldType {
  CHttpCookie::eField_Name , CHttpCookie::eField_Value , CHttpCookie::eField_Domain , CHttpCookie::eField_Path ,
  CHttpCookie::eField_Extension , CHttpCookie::eField_Other
}
 Cookie field selector. More...
 
enum  CHttpCookies::ECookieHeader { CHttpCookies::eHeader_Cookie , CHttpCookies::eHeader_SetCookie }
 Cookie header type. More...
 
enum  CHttpCookieException::EErrCode { CHttpCookieException::eValue , CHttpCookieException::eIterator , CHttpCookieException::eOther }
 

Functions

 CHttpCookie::CHttpCookie (void)
 Create an empty cookie. More...
 
 CHttpCookie::CHttpCookie (const CTempString &name, const CTempString &value, const CTempString &domain=kEmptyStr, const CTempString &path=kEmptyStr)
 Create a cookie with the given attributes. More...
 
const stringCHttpCookie::GetName (void) const
 Get cookie's name. No encoding/decoding is performed. More...
 
const stringCHttpCookie::GetValue (void) const
 Get cookie's value. No encoding/decoding is performed. More...
 
const stringCHttpCookie::GetDomain (void) const
 Get domain. More...
 
bool CHttpCookie::GetHostOnly (void) const
 Get host-only flag. More...
 
const stringCHttpCookie::GetPath (void) const
 Get path. More...
 
string CHttpCookie::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 CTimeCHttpCookie::GetExpirationTime (void) const
 The returned CTime may be empty if expiration date is not set. More...
 
bool CHttpCookie::GetSecure (void) const
 Get secure flag. More...
 
bool CHttpCookie::GetHttpOnly (void) const
 Get HTTP-only flag. More...
 
const stringCHttpCookie::GetExtension (void) const
 Get any unparsed attributes merged into a single line using semicolon separators. More...
 
void CHttpCookie::SetName (const CTempString &name)
 Set cookie's name. More...
 
void CHttpCookie::SetValue (const CTempString &value)
 Set cookie's value. More...
 
void CHttpCookie::SetDomain (const CTempString &domain)
 Set cookie's domain. More...
 
void CHttpCookie::SetHostOnly (bool host_only)
 Set host-only flag. More...
 
void CHttpCookie::SetPath (const CTempString &path)
 Set cookie's path. More...
 
void CHttpCookie::SetExpirationTime (const CTime &exp_time)
 Set expiration time, must be a GMT one. More...
 
void CHttpCookie::SetSecure (bool secure)
 Set secure flag. More...
 
void CHttpCookie::SetHttpOnly (bool http_only)
 Set HTTP-only flag. More...
 
void CHttpCookie::SetExtension (const CTempString &extension)
 Any additional attributes (multiple attributes should be separated with semicolon). More...
 
bool CHttpCookie::IsExpired (void) const
 Check if the cookie is currently expired. More...
 
bool CHttpCookie::IsExpired (const CTime &now) const
 Check if the cookie has expired by "now". More...
 
bool CHttpCookie::Validate (void) const
 Check if name, value, domain and path of the cookie are valid. More...
 
string CHttpCookie::AsString (ECookieFormat format) const
 Compose string from the cookie. More...
 
bool CHttpCookie::Parse (const CTempString &str)
 Read cookie from the string. More...
 
bool CHttpCookie::operator< (const CHttpCookie &cookie) const
 Compare two cookies: More...
 
bool CHttpCookie::operator== (const CHttpCookie &cookie) const
 Compare two cookies. More...
 
bool CHttpCookie::Match (const CUrl &url) const
 Check if the cookie matches domain, path and scheme of the URL. More...
 
bool CHttpCookie::MatchDomain (const string &host) const
 Helper method for string matching. More...
 
bool CHttpCookie::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 CHttpCookie::Reset (void)
 Reset value and all attributes, keep just the name. More...
 
static bool CHttpCookie::IsValidValue (const string &value, EFieldType field, string *err_msg=NULL)
 Check if the value can be safely used for the selected field. More...
 
void CHttpCookie::x_Validate (const string &value, EFieldType field) const
 
static int CHttpCookie::sx_Compare (const CHttpCookie &c1, const CHttpCookie &c2)
 
virtual CHttpCookies::~CHttpCookies (void)
 
void CHttpCookies::Add (const CHttpCookie &cookie)
 Add a single cookie. More...
 
size_t CHttpCookies::Add (ECookieHeader header, const CTempString &str, const CUrl *url)
 Parse a single Cookie or Set-Cookie header, discard bad cookies. More...
 
void CHttpCookies::Cleanup (size_t max_count=0)
 Cleanup cookies. More...
 
const_iterator CHttpCookies::begin (void) const
 Iterate all cookies. More...
 
const_iterator CHttpCookies::begin (const CUrl &url) const
 Iterate cookies matching the given URL. More...
 
const_iterator CHttpCookies::end (void) const
 Empty iterator. More...
 
bool CHttpCookies::SDomainLess::operator() (const string &s1, const string &s2) const
 
CHttpCookieCHttpCookies::x_Find (const string &domain, const string &path, const string &name)
 
static string CHttpCookies::sx_RevertDomain (const string &domain)
 
 CHttpCookie_CI::CHttpCookie_CI (void)
 
 CHttpCookie_CI::CHttpCookie_CI (const CHttpCookie_CI &other)
 
CHttpCookie_CICHttpCookie_CI::operator= (const CHttpCookie_CI &other)
 
 CHttpCookie_CI::operator bool (void) const
 
bool CHttpCookie_CI::operator== (const CHttpCookie_CI &other) const
 
bool CHttpCookie_CI::operator!= (const CHttpCookie_CI &other) const
 
CHttpCookie_CICHttpCookie_CI::operator++ (void)
 
const CHttpCookieCHttpCookie_CI::operator* (void) const
 
const CHttpCookieCHttpCookie_CI::operator-> (void) const
 
 CHttpCookie_CI::CHttpCookie_CI (const CHttpCookies &cookies, const CUrl *url)
 
bool CHttpCookie_CI::x_IsValid (void) const
 
void CHttpCookie_CI::x_CheckState (void) const
 
int CHttpCookie_CI::x_Compare (const CHttpCookie_CI &other) const
 
void CHttpCookie_CI::x_Next (void)
 
void CHttpCookie_CI::x_Settle (void)
 
virtual const char * CHttpCookieException::GetErrCodeString (void) const override
 Get error code interpreted as text. More...
 
 CHttpCookieException::NCBI_EXCEPTION_DEFAULT (CHttpCookieException, CException)
 

Variables

string CHttpCookie::m_Name
 
string CHttpCookie::m_Value
 
string CHttpCookie::m_Domain
 
string CHttpCookie::m_Path
 
CTime CHttpCookie::m_Expires
 
bool CHttpCookie::m_Secure
 
bool CHttpCookie::m_HttpOnly
 
string CHttpCookie::m_Extension
 
CTime CHttpCookie::m_Created
 
CTime CHttpCookie::m_Accessed
 
bool CHttpCookie::m_HostOnly
 
TCookieMap CHttpCookies::m_CookieMap
 
const CHttpCookiesCHttpCookie_CI::m_Cookies
 
CUrl CHttpCookie_CI::m_Url
 
TMap_CI CHttpCookie_CI::m_MapIt
 
TList_CI CHttpCookie_CI::m_ListIt
 

Friends

class CHttpCookies::CHttpCookie
 
class CHttpCookies::CHttpCookie_CI
 
class CHttpCookie_CI::CHttpCookies
 

Detailed Description

Typedef Documentation

◆ const_iterator

Allow to use cookies with macros like ITERATE.

Definition at line 292 of file ncbi_cookies.hpp.

◆ TCookieList [1/2]

Definition at line 309 of file ncbi_cookies.hpp.

◆ TCookieList [2/2]

Definition at line 370 of file ncbi_cookies.hpp.

◆ TCookieMap [1/2]

Definition at line 310 of file ncbi_cookies.hpp.

◆ TCookieMap [2/2]

Definition at line 372 of file ncbi_cookies.hpp.

◆ TList_CI

typedef TCookieList::const_iterator CHttpCookie_CI::TList_CI
private

Definition at line 371 of file ncbi_cookies.hpp.

◆ TMap_CI

Definition at line 373 of file ncbi_cookies.hpp.

Enumeration Type Documentation

◆ ECookieFormat

Whether the cookie is sent as a part of HTTP request or HTTP response.

Enumerator
eHTTPResponse 
eHTTPRequest 

Definition at line 146 of file ncbi_cookies.hpp.

◆ ECookieHeader

Cookie header type.

Enumerator
eHeader_Cookie 
eHeader_SetCookie 

Definition at line 255 of file ncbi_cookies.hpp.

◆ EErrCode

Enumerator
eValue 
eIterator 
eOther 

Definition at line 391 of file ncbi_cookies.hpp.

◆ EFieldType

Cookie field selector.

Enumerator
eField_Name 
eField_Value 
eField_Domain 
eField_Path 
eField_Extension 
eField_Other 

Definition at line 200 of file ncbi_cookies.hpp.

Function Documentation

◆ Add() [1/2]

void CHttpCookies::Add ( const CHttpCookie cookie)

Add a single cookie.

If a cookie with the same name/domain/path exists, update its value, expiration and flags.

Definition at line 707 of file ncbi_cookies.cpp.

References CHttpCookie::GetDomain(), CHttpCookie::GetName(), CHttpCookie::GetPath(), CHttpCookies::m_CookieMap, CHttpCookies::sx_RevertDomain(), and CHttpCookies::x_Find().

Referenced by CHttpCookies::Add(), and CHttpSession_Base::x_SetCookies().

◆ Add() [2/2]

size_t CHttpCookies::Add ( ECookieHeader  header,
const CTempString str,
const CUrl url 
)

Parse a single Cookie or Set-Cookie header, discard bad cookies.

Parameters
headereHeader_Cookie: the string may contain multiple name/value pairs. eHeader_SetCookie: the method reads a single Set-Cookie line and matches the cookie using the url (if any) and discards the cookie if it does not pass matching.
strString containing a single HTTP-response cookie or multiple HTTP-request cookies depending on 'header' value. The string must not contain 'Set-Cookie:' or 'Cookie:' text.
urlIf not null, the parsed cookie is matched against the url. If an attribute does not pass matching (domain, path, secure, http-only) the whole cookie is discarded.
Returns
Number of cookies parsed successfully. In case of eHeader_SetCookie the returned value is always 1 or 0.

Definition at line 720 of file ncbi_cookies.cpp.

References CHttpCookies::Add(), CHttpCookies::Cleanup(), count, CHttpCookies::eHeader_Cookie, NStr::fSplit_MergeDelimiters, NStr::fSplit_Truncate, CHttpCookie::GetDomain(), CUrl::GetHost(), CHttpCookie::GetName(), CHttpCookie::GetPath(), CUrl::GetPath(), CHttpCookie::IsExpired(), ITERATE, CHttpCookie::Match(), CHttpCookie::Parse(), CHttpCookie::SetDomain(), CHttpCookie::SetHostOnly(), CHttpCookie::SetPath(), NStr::Split(), str(), and CHttpCookies::x_Find().

◆ AsString()

string CHttpCookie::AsString ( ECookieFormat  format) const

Compose string from the cookie.

If quoting is enabled, the value is placed in double-quotes. NOTE that this method does not print 'Set-Cookie:' or 'Cookie:' header itself, just the cookie value.

Parameters
format
  • eHTTPResponse: name=value[; expires=date; path=val_path; domain=dom_name; secure; http_only; extension]
  • eHTTPRequest: name=value

Definition at line 214 of file ncbi_cookies.cpp.

References CHttpCookie::eField_Domain, CHttpCookie::eField_Extension, CHttpCookie::eField_Name, CHttpCookie::eField_Path, CHttpCookie::eField_Value, CHttpCookie::eHTTPRequest, CHttpCookie::eHTTPResponse, format, CHttpCookie::GetExpirationStr(), CTime::IsEmpty(), CHttpCookie::m_Accessed, CHttpCookie::m_Domain, CHttpCookie::m_Expires, CHttpCookie::m_Extension, CHttpCookie::m_HttpOnly, CHttpCookie::m_Name, CHttpCookie::m_Path, CHttpCookie::m_Secure, CHttpCookie::m_Value, CTime::SetCurrent(), and CHttpCookie::x_Validate().

Referenced by CHttpSession_Base::x_GetCookies().

◆ begin() [1/2]

CHttpCookie_CI CHttpCookies::begin ( const CUrl url) const
inline

Iterate cookies matching the given URL.

Definition at line 524 of file ncbi_cookies.hpp.

References CHttpCookies::CHttpCookie_CI.

◆ begin() [2/2]

CHttpCookie_CI CHttpCookies::begin ( void  ) const
inline

Iterate all cookies.

Definition at line 518 of file ncbi_cookies.hpp.

References CHttpCookies::CHttpCookie_CI, and NULL.

Referenced by CHttpSession_Base::x_GetCookies().

◆ CHttpCookie() [1/2]

CHttpCookie::CHttpCookie ( const CTempString name,
const CTempString value,
const CTempString domain = kEmptyStr,
const CTempString path = kEmptyStr 
)

Create a cookie with the given attributes.

No validation is performed at this time except that the name can not be empty.

Definition at line 77 of file ncbi_cookies.cpp.

References CHttpCookie::m_Name, NCBI_THROW, and CHttpCookie::SetDomain().

◆ CHttpCookie() [2/2]

CHttpCookie::CHttpCookie ( void  )

Create an empty cookie.

Definition at line 66 of file ncbi_cookies.cpp.

◆ CHttpCookie_CI() [1/3]

CHttpCookie_CI::CHttpCookie_CI ( const CHttpCookie_CI other)

Definition at line 898 of file ncbi_cookies.cpp.

◆ CHttpCookie_CI() [2/3]

CHttpCookie_CI::CHttpCookie_CI ( const CHttpCookies cookies,
const CUrl url 
)
private

◆ CHttpCookie_CI() [3/3]

CHttpCookie_CI::CHttpCookie_CI ( void  )

Definition at line 872 of file ncbi_cookies.cpp.

◆ Cleanup()

void CHttpCookies::Cleanup ( size_t  max_count = 0)

Cleanup cookies.

Remove the expired ones first, then if the remaining number of cookies is above the limit, remove domains containing most cookies until the total number is below the limit.

Definition at line 791 of file ncbi_cookies.cpp.

References _ASSERT, map_checker< Container >::clear(), count, map_checker< Container >::end(), map_checker< Container >::erase(), ERASE_ITERATE, map_checker< Container >::find(), ITERATE, CHttpCookies::m_CookieMap, and s_DomainCountLess().

Referenced by CHttpCookies::Add().

◆ end()

CHttpCookie_CI CHttpCookies::end ( void  ) const
inline

Empty iterator.

Definition at line 530 of file ncbi_cookies.hpp.

References CHttpCookies::CHttpCookie_CI.

◆ GetDomain()

const string & CHttpCookie::GetDomain ( void  ) const
inline

Get domain.

Definition at line 427 of file ncbi_cookies.hpp.

References CHttpCookie::m_Domain.

Referenced by CHttpCookies::Add().

◆ GetErrCodeString()

const char * CHttpCookieException::GetErrCodeString ( void  ) const
overridevirtual

Get error code interpreted as text.

Reimplemented from CException.

Definition at line 1013 of file ncbi_cookies.cpp.

References CHttpCookieException::eIterator, CHttpCookieException::eValue, CException::GetErrCode(), and CException::GetErrCodeString().

◆ GetExpirationStr()

string CHttpCookie::GetExpirationStr ( void  ) const

Get string representaion of expiration time (dd-Mon-yyyy hh:mm:ss GMT) or empty string if expiration is not set.

Definition at line 98 of file ncbi_cookies.cpp.

References CTime::AsString(), CTime::IsEmpty(), kCookieTimeFormat(), kEmptyStr, and CHttpCookie::m_Expires.

Referenced by CHttpCookie::AsString().

◆ GetExpirationTime()

const CTime & CHttpCookie::GetExpirationTime ( void  ) const
inline

The returned CTime may be empty if expiration date is not set.

Definition at line 442 of file ncbi_cookies.hpp.

References CHttpCookie::m_Expires.

◆ GetExtension()

const string & CHttpCookie::GetExtension ( void  ) const
inline

Get any unparsed attributes merged into a single line using semicolon separators.

Definition at line 457 of file ncbi_cookies.hpp.

References CHttpCookie::m_Extension.

◆ GetHostOnly()

bool CHttpCookie::GetHostOnly ( void  ) const
inline

Get host-only flag.

The flag is set if the incoming cookie contains no domain attribute. In this case the domain is set to the originating host but no domain matching is used and the cookie can be sent back only to the same domain.

Definition at line 432 of file ncbi_cookies.hpp.

References CHttpCookie::m_HostOnly.

◆ GetHttpOnly()

bool CHttpCookie::GetHttpOnly ( void  ) const
inline

Get HTTP-only flag.

If set, the cookie can only be sent through http or https connection.

Definition at line 452 of file ncbi_cookies.hpp.

References CHttpCookie::m_HttpOnly.

◆ GetName()

const string & CHttpCookie::GetName ( void  ) const
inline

Get cookie's name. No encoding/decoding is performed.

Definition at line 417 of file ncbi_cookies.hpp.

References CHttpCookie::m_Name.

Referenced by CHttpCookies::Add().

◆ GetPath()

const string & CHttpCookie::GetPath ( void  ) const
inline

Get path.

Definition at line 437 of file ncbi_cookies.hpp.

References CHttpCookie::m_Path.

Referenced by CHttpCookies::Add().

◆ GetSecure()

bool CHttpCookie::GetSecure ( void  ) const
inline

Get secure flag.

If set, the cookie can only be sent through a secure connections.

Definition at line 447 of file ncbi_cookies.hpp.

References CHttpCookie::m_Secure.

◆ GetValue()

const string & CHttpCookie::GetValue ( void  ) const
inline

Get cookie's value. No encoding/decoding is performed.

Definition at line 422 of file ncbi_cookies.hpp.

References CHttpCookie::m_Value.

◆ IsExpired() [1/2]

bool CHttpCookie::IsExpired ( const CTime now) const

Check if the cookie has expired by "now".

Return false if the expiration time is not set.

Definition at line 108 of file ncbi_cookies.cpp.

References false, CTime::IsEmpty(), and CHttpCookie::m_Expires.

◆ IsExpired() [2/2]

bool CHttpCookie::IsExpired ( void  ) const
inline

Check if the cookie is currently expired.

Definition at line 512 of file ncbi_cookies.hpp.

References CTime::eCurrent, and CTime::eGmt.

Referenced by CHttpCookies::Add().

◆ IsValidValue()

bool CHttpCookie::IsValidValue ( const string value,
EFieldType  field,
string err_msg = NULL 
)
static

Check if the value can be safely used for the selected field.

If the value is not valid and err_msg is not NULL, save error description to the string.

Definition at line 114 of file ncbi_cookies.cpp.

References _ASSERT, CHttpCookie::eField_Domain, CHttpCookie::eField_Extension, CHttpCookie::eField_Name, CHttpCookie::eField_Path, CHttpCookie::eField_Value, isalnum(), iscntrl(), kBannedChars_Extension, kBannedChars_Name, kBannedChars_Path, kBannedChars_Value, NPOS, NStr::SizetToString(), string, and rapidjson::value.

Referenced by CHttpCookie::Parse(), CHttpCookie::Validate(), and CHttpCookie::x_Validate().

◆ Match()

bool CHttpCookie::Match ( const CUrl url) const

◆ MatchDomain()

bool CHttpCookie::MatchDomain ( const string host) const

Helper method for string matching.

Cookie domain matches the 'host' if they are identical or 'host' ends with cookie domain and the last non-matching char in 'host' is '.'. If HostOnly flag is set, cookie domain must be identical to the host, no partial matching is used.

Definition at line 630 of file ncbi_cookies.cpp.

References CHttpCookie::m_Domain, CHttpCookie::m_HostOnly, NPOS, and NStr::ToLower().

Referenced by CHttpCookie::Match().

◆ MatchPath()

bool CHttpCookie::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 '/'.

The last segment of 'path' (anything after the last '/') is ignored.

Definition at line 650 of file ncbi_cookies.cpp.

References CHttpCookie::m_Path, next(), NPOS, and NStr::StartsWith().

Referenced by CHttpCookie::Match().

◆ NCBI_EXCEPTION_DEFAULT()

CHttpCookieException::NCBI_EXCEPTION_DEFAULT ( CHttpCookieException  ,
CException   
)

◆ operator bool()

CHttpCookie_CI::operator bool ( void  ) const
inline

Definition at line 536 of file ncbi_cookies.hpp.

◆ operator!=()

bool CHttpCookie_CI::operator!= ( const CHttpCookie_CI other) const
inline

Definition at line 548 of file ncbi_cookies.hpp.

References CHttpCookie_CI::x_Compare().

◆ operator()()

bool CHttpCookies::SDomainLess::operator() ( const string s1,
const string s2 
) const
inline

Definition at line 305 of file ncbi_cookies.hpp.

References NStr::CompareNocase().

◆ operator*()

const CHttpCookie & CHttpCookie_CI::operator* ( void  ) const

Definition at line 926 of file ncbi_cookies.cpp.

References CHttpCookie_CI::m_ListIt, and CHttpCookie_CI::x_CheckState().

◆ operator++()

CHttpCookie_CI & CHttpCookie_CI::operator++ ( void  )

◆ operator->()

const CHttpCookie * CHttpCookie_CI::operator-> ( void  ) const

Definition at line 933 of file ncbi_cookies.cpp.

References CHttpCookie_CI::x_CheckState().

◆ operator<()

bool CHttpCookie::operator< ( const CHttpCookie cookie) const

Compare two cookies:

  • longer domains go first, otherwise compare without case;
  • longer paths go first, otherwise compare with case;
  • compare names (no case);
  • (though this should not happen) compare creation time.

Definition at line 306 of file ncbi_cookies.cpp.

References CHttpCookie::sx_Compare().

◆ operator=()

CHttpCookie_CI & CHttpCookie_CI::operator= ( const CHttpCookie_CI other)

◆ operator==() [1/2]

bool CHttpCookie::operator== ( const CHttpCookie cookie) const

Compare two cookies.

Definition at line 312 of file ncbi_cookies.cpp.

References CHttpCookie::sx_Compare().

◆ operator==() [2/2]

bool CHttpCookie_CI::operator== ( const CHttpCookie_CI other) const
inline

Definition at line 542 of file ncbi_cookies.hpp.

References CHttpCookie_CI::x_Compare().

◆ Parse()

bool CHttpCookie::Parse ( const CTempString str)

Read cookie from the string.

The string should not include 'Cookie:' or 'Set-Cookie:' header. In case of HTTP request cookies ('Cookie:' header) the input should contain only one name=value pair. Return true on success, false on error (bad symbols in name/value, invalid domain, inproper protocol etc. - see RFC-6265). Parsing errors are logged with 'Info' severity.

Definition at line 461 of file ncbi_cookies.cpp.

References CTime::AddSecond(), CTime::Clear(), CHttpCookie::eField_Domain, CHttpCookie::eField_Name, CHttpCookie::eField_Path, CHttpCookie::eField_Value, CTime::eGmt, NStr::EndsWith(), NStr::EqualNocase(), ERR_POST_X, ncbi::grid::netcache::search::fields::expires, NStr::fSplit_MergeDelimiters, NStr::fSplit_Truncate, Info(), CTime::IsEmpty(), CHttpCookie::IsValidValue(), ITERATE, CHttpCookie::m_Accessed, CHttpCookie::m_Created, CHttpCookie::m_Domain, CHttpCookie::m_Expires, CHttpCookie::m_Extension, CHttpCookie::m_HostOnly, CHttpCookie::m_HttpOnly, CHttpCookie::m_Name, CHttpCookie::m_Path, CHttpCookie::m_Secure, CHttpCookie::m_Value, NPOS, s_ParseDateTime(), CTime::SetCurrent(), CTime::SetTimeZone(), NStr::Split(), str(), NStr::ToLower(), NStr::TruncateSpaces(), and rapidjson::value.

Referenced by CHttpCookies::Add().

◆ Reset()

void CHttpCookie::Reset ( void  )

◆ SetDomain()

void CHttpCookie::SetDomain ( const CTempString domain)
inline

Set cookie's domain.

The value is converted to lower case and the leading '.' is trimmed (if any). No other validation is performed immediately, but if the value is invalid CHttpCookieExcepion will be thrown on an attempt to get the cookie as a string.

See also
AsString()

Definition at line 472 of file ncbi_cookies.hpp.

References CHttpCookie::m_Domain, and NStr::ToLower().

Referenced by CHttpCookies::Add(), and CHttpCookie::CHttpCookie().

◆ SetExpirationTime()

void CHttpCookie::SetExpirationTime ( const CTime exp_time)
inline

Set expiration time, must be a GMT one.

Definition at line 486 of file ncbi_cookies.hpp.

References CHttpCookie::m_Expires.

◆ SetExtension()

void CHttpCookie::SetExtension ( const CTempString extension)
inline

Any additional attributes (multiple attributes should be separated with semicolon).

The string is appended to the cookie, semicolon-separated when converting it to a string.

Definition at line 501 of file ncbi_cookies.hpp.

References CHttpCookie::m_Extension.

◆ SetHostOnly()

void CHttpCookie::SetHostOnly ( bool  host_only)
inline

Set host-only flag.

If the flag is true, the domain must be identical to the host when sending the cookie back (rather than just match it).

Definition at line 506 of file ncbi_cookies.hpp.

References CHttpCookie::m_HostOnly.

Referenced by CHttpCookies::Add().

◆ SetHttpOnly()

void CHttpCookie::SetHttpOnly ( bool  http_only)
inline

Set HTTP-only flag.

If set, the cookie can only be sent through http or https connection. Unset by default.

Definition at line 496 of file ncbi_cookies.hpp.

References CHttpCookie::m_HttpOnly.

◆ SetName()

void CHttpCookie::SetName ( const CTempString name)
inline

Set cookie's name.

No validation is performed immediately, but if the value is invalid CHttpCookieExcepion will be thrown on an attempt to get the cookie as a string. The name is never encoded - the caller is responsible for providing a valid name.

See also
AsString()

Definition at line 462 of file ncbi_cookies.hpp.

References CHttpCookie::m_Name.

◆ SetPath()

void CHttpCookie::SetPath ( const CTempString path)
inline

Set cookie's path.

No validation is performed immediately, but if the value is invalid CHttpCookieExcepion will be thrown on an attempt to get the cookie as a string.

See also
AsString()

Definition at line 481 of file ncbi_cookies.hpp.

References CHttpCookie::m_Path.

Referenced by CHttpCookies::Add().

◆ SetSecure()

void CHttpCookie::SetSecure ( bool  secure)
inline

Set secure flag.

If set, the cookie can only be sent through a secure connection. Unset by default.

Definition at line 491 of file ncbi_cookies.hpp.

References CHttpCookie::m_Secure.

◆ SetValue()

void CHttpCookie::SetValue ( const CTempString value)
inline

Set cookie's value.

No validation is performed immediately, but if the value is invalid CHttpCookieExcepion will be thrown on an attempt to get the cookie as a string. The value is never encoded - the caller is responsible for providing a valid value.

See also
AsString()

Definition at line 467 of file ncbi_cookies.hpp.

References CHttpCookie::m_Value, and rapidjson::value.

◆ sx_Compare()

int CHttpCookie::sx_Compare ( const CHttpCookie c1,
const CHttpCookie c2 
)
staticprivate

◆ sx_RevertDomain()

string CHttpCookies::sx_RevertDomain ( const string domain)
staticprivate

◆ Validate()

bool CHttpCookie::Validate ( void  ) const

◆ x_CheckState()

void CHttpCookie_CI::x_CheckState ( void  ) const
private

◆ x_Compare()

int CHttpCookie_CI::x_Compare ( const CHttpCookie_CI other) const
private

◆ x_Find()

CHttpCookie * CHttpCookies::x_Find ( const string domain,
const string path,
const string name 
)
private

◆ x_IsValid()

bool CHttpCookie_CI::x_IsValid ( void  ) const
private

◆ x_Next()

void CHttpCookie_CI::x_Next ( void  )
private

◆ x_Settle()

void CHttpCookie_CI::x_Settle ( void  )
private

◆ x_Validate()

void CHttpCookie::x_Validate ( const string value,
EFieldType  field 
) const
private

◆ ~CHttpCookies()

CHttpCookies::~CHttpCookies ( void  )
virtual

Definition at line 702 of file ncbi_cookies.cpp.

Variable Documentation

◆ m_Accessed

CTime CHttpCookie::m_Accessed
mutableprivate

Definition at line 231 of file ncbi_cookies.hpp.

Referenced by CHttpCookie::AsString(), CHttpCookie::Parse(), and CHttpCookie::Reset().

◆ m_CookieMap

TCookieMap CHttpCookies::m_CookieMap
private

◆ m_Cookies

const CHttpCookies* CHttpCookie_CI::m_Cookies
private

◆ m_Created

CTime CHttpCookie::m_Created
private

◆ m_Domain

string CHttpCookie::m_Domain
private

◆ m_Expires

CTime CHttpCookie::m_Expires
private

◆ m_Extension

string CHttpCookie::m_Extension
private

◆ m_HostOnly

bool CHttpCookie::m_HostOnly
private

◆ m_HttpOnly

bool CHttpCookie::m_HttpOnly
private

◆ m_ListIt

TList_CI CHttpCookie_CI::m_ListIt
private

◆ m_MapIt

TMap_CI CHttpCookie_CI::m_MapIt
private

◆ m_Name

string CHttpCookie::m_Name
private

◆ m_Path

string CHttpCookie::m_Path
private

◆ m_Secure

bool CHttpCookie::m_Secure
private

◆ m_Url

CUrl CHttpCookie_CI::m_Url
private

Definition at line 376 of file ncbi_cookies.hpp.

Referenced by CHttpCookie_CI::CHttpCookie_CI(), and CHttpCookie_CI::x_IsValid().

◆ m_Value

string CHttpCookie::m_Value
private

Friends

◆ CHttpCookie

friend class CHttpCookie
friend

Definition at line 313 of file ncbi_cookies.hpp.

◆ CHttpCookie_CI

friend class CHttpCookie_CI
friend

Definition at line 314 of file ncbi_cookies.hpp.

Referenced by CHttpCookies::begin(), and CHttpCookies::end().

◆ CHttpCookies

friend class CHttpCookies
friend

Definition at line 354 of file ncbi_cookies.hpp.

Modified on Wed Sep 04 15:04:52 2024 by modify_doxy.py rev. 669887