allow_empty =
true;
124allow_empty =
false;
142 for(
size_tpos = 0; pos <
value.size(); ++pos) {
143 charc =
value[pos];
144 if(pos > 0 && c ==
'-') {
148 if(pos > 0 && c ==
'.'&&
value[pos - 1] !=
'.') {
154*err_msg =
string(
"Banned char '") +
value[pos] +
155 "' in cookie domain: "+
value+
168 boolvalid = allow_empty || !
value.empty();
170string::size_type pos =
value.find_first_of(banned);
176 for(pos = 0; pos <
value.size(); ++pos) {
183 if(!valid && err_msg ) {
184*err_msg =
string(
"Banned char '") +
value[pos] +
185 "' in cookie "+ attr +
": "+
value+
232 if( !
m_Path.empty() ) {
233ret +=
"; Path="+
m_Path;
242ret +=
"; HttpOnly";
338 if(
value.size() < 5)
return-1;
339 int f[3] = {-1, -1, -1};
342 for(
int i= 0;
i< 3; ++
i) {
343 if(p >=
value.size())
break;
347 if(p >=
value.size())
break;
348 if(
value[p] !=
':') {
353 if(p >=
value.size())
break;
354 if(
value[p] !=
':')
return-1;
359 if(
f[0] < 0 ||
f[1] < 0 ||
f[2] < 0) {
364 if(
f[0] > 23 ||
f[1] > 59 ||
f[2] > 59)
return-2;
366 return f[0]*3600 +
f[1]*60 +
f[2];
373 static const char* kMonthNames =
"jan feb mar apr may jun jul aug sep oct nov dec ";
374 static const char* kDayOfWeekNames =
"sun mon tue wed thu fri sat ";
379 size_ttoken_pos = 0;
384 for(; pos <=
value.size(); ++pos) {
385 charc = pos <
value.size() ?
value[pos] :
';';
387 if(
isalnum(c) || c ==
':')
continue;
389 if(pos - token_pos < 1) {
394 stringfield =
value.substr(token_pos, pos - token_pos);
398 if(time < 0 && field.size() > 4 && (field[1] ==
':'|| field[2] ==
':')) {
400 if(time >= 0)
continue;
408 if(day < 0 && field.size() <= 2) {
410 if(day < 1 || day > 31) {
418 if(mon <= 0 && field.size() == 3) {
421mon =
int(mpos/4 + 1);
436 if(year < 0 && (field.size() == 2 || field.size() == 4)) {
438 if(year == 0 && errno != 0) {
443year += (year < 70) ? 2000 : 1900;
452 if(time < 0 || day < 0 || mon < 0 || year < 0) {
478 size_tpos =
str.find(
';');
479 stringnv =
str.substr(0, pos);
480 stringattr_str =
str.substr(pos + 1);
481pos = nv.find(
'=');
506 if( attr_str.empty() ) {
515 ITERATE(list<string>, it, attrs) {
516pos = it->find(
'=');
570 if( !name.empty() ) {
572 if( !
value.empty() ) {
576 if( !
value.empty() ) {
582 if( !maxage.empty() ) {
584 Uint8sec = NStr::StringToNumeric<Uint8>(maxage);
585 if(sec == 0 && errno) {
586 ERR_POST_X(6,
Info<<
"Invalid MaxAge value in cookie: "<< maxage);
595 else if( !
expires.empty() ) {
642pos +
m_Domain.size() != h.size() ||
643(pos > 0 && h[pos - 1] !=
'.')) {
658 size_tlast_sep = p.find(
'/');
659 if(last_sep !=
NPOS) {
661 while((
next= p.find(
'/', last_sep + 1)) !=
NPOS) {
665 if(p.empty() || p[0] !=
'/'|| last_sep ==
NPOS) {
668 else if(last_sep > 0) {
669p = p.substr(0, last_sep);
730list<string> cookies;
733 ITERATE(list<string>, it, cookies) {
734 if( cookie.
Parse(*it) ) {
755 if( cookie.
GetPath().empty() ) {
762 if(found && !found->
Match(*url)) {
766 if( !cookie.
Match(*url) ) {
787 returndc1.second > dc2.second;
799 if( list_it->IsExpired() ) {
800map_it->second.erase(list_it);
803 if( map_it->second.empty() ) {
809domains.push_back(dc);
813 if(max_count == 0 ||
count<= max_count) {
824 if(
count<= max_count) {
839 if(domain_it !=
m_CookieMap.
end() && domain_it->first == rdomain) {
841 if(path == it->GetPath() &&
858 if( !ret.empty() ) {
879: m_Cookies(&cookies)
906 if(
this!= &other) {
1016 case eValue:
return "Bad cookie";
1017 case eIterator:
return "Ivalid cookie iterator";
@ eEmpty
no filtering at all.
CHttpCookieException â.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
const_iterator lower_bound(const key_type &key) const
const_iterator find(const key_type &key) const
static const struct name_t names[]
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERASE_ITERATE(Type, Var, Cont)
Non-constant version with ability to erase current element, if container permits.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define REVERSE_ITERATE(Type, Var, Cont)
ITERATE macro to reverse sequence through container elements.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
void Info(CExceptionArgs_Base &args)
bool operator==(const CHttpCookie &cookie) const
Compare two cookies.
void SetPath(const CTempString &path)
Set cookie's path.
const string & GetPath(void) const
Get path.
static bool IsValidValue(const string &value, EFieldType field, string *err_msg=NULL)
Check if the value can be safely used for the selected field.
void Cleanup(size_t max_count=0)
Cleanup cookies.
bool Validate(void) const
Check if name, value, domain and path of the cookie are valid.
CHttpCookie(void)
Create an empty cookie.
EFieldType
Cookie field selector.
const string & GetDomain(void) const
Get domain.
const string & GetName(void) const
Get cookie's name. No encoding/decoding is performed.
void x_Validate(const string &value, EFieldType field) const
string GetExpirationStr(void) const
Get string representaion of expiration time (dd-Mon-yyyy hh:mm:ss GMT) or empty string if expiration ...
bool IsExpired(void) const
Check if the cookie is currently expired.
const CHttpCookie & operator*(void) const
void SetHostOnly(bool host_only)
Set host-only flag.
bool operator<(const CHttpCookie &cookie) const
Compare two cookies:
void x_CheckState(void) const
ECookieHeader
Cookie header type.
list< CHttpCookie > TCookieList
bool MatchDomain(const string &host) const
Helper method for string matching.
string AsString(ECookieFormat format) const
Compose string from the cookie.
static string sx_RevertDomain(const string &domain)
const CHttpCookies * m_Cookies
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
CHttpCookie * x_Find(const string &domain, const string &path, const string &name)
CHttpCookie_CI & operator=(const CHttpCookie_CI &other)
void Add(const CHttpCookie &cookie)
Add a single cookie.
CHttpCookie_CI & operator++(void)
bool x_IsValid(void) const
void SetDomain(const CTempString &domain)
Set cookie's domain.
bool Parse(const CTempString &str)
Read cookie from the string.
ECookieFormat
Whether the cookie is sent as a part of HTTP request or HTTP response.
void Reset(void)
Reset value and all attributes, keep just the name.
static int sx_Compare(const CHttpCookie &c1, const CHttpCookie &c2)
virtual ~CHttpCookies(void)
const CHttpCookie * operator->(void) const
int x_Compare(const CHttpCookie_CI &other) const
bool MatchPath(const string &path) const
'path' matches if it starts with 'cookie_path' and the last matching char or the first non-matching c...
bool Match(const CUrl &url) const
Check if the cookie matches domain, path and scheme of the URL.
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
int Compare(const T &s1, const T &s2) const
Return difference between "s1" and "s2".
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string.
static string & ToLower(string &str)
Convert string to lower case â string& version.
@ fConvErr_NoThrow
Do not throw an exception on error.
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
ETimeZone SetTimeZone(ETimeZone val)
Set time zone.
CTime & AddSecond(TSeconds seconds=1, EDaylight adl=eDaylightDefault)
Add specified seconds.
CTime & Clear(void)
Make the time "empty",.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
bool IsEmpty(void) const
Is time object empty (date and time)?
CTime & SetCurrent(void)
Make the time current in the presently active time zone.
@ eEmpty
Use "empty" time.
@ eGmt
GMT (Greenwich Mean Time)
const string & GetHost(void) const
const string & GetPath(void) const
const string & GetScheme(void) const
unsigned int
A callback function used to compare two keys in a database.
Definition of all error codes used in corelib (xncbi.lib).
The blob sat and sat key Both must be positive integers</td > n< td > Non empty string The interpretation of the blob id depends on a processor Cassandra n processor expects the following format
const struct ncbi::grid::netcache::search::fields::EXPIRES expires
const GenericPointer< typename T::ValueType > T2 value
static const char * kBannedChars_Path
static bool s_DomainCountLess(const TDomainCount &dc1, const TDomainCount &dc2)
static const char * kBannedChars_Extension
CTime s_ParseDateTime(const string &value)
static const CTimeFormat kCookieTimeFormat("w, D b Y h:m:s Z")
static const char * kBannedChars_Name
list< TDomainCount > TDomainList
int s_ParseTime(const string &value)
pair< string, size_t > TDomainCount
static const char * kBannedChars_Value
Defines NCBI C++ diagnostic APIs, classes, and macros.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4