CCookie Class Reference

class CCookie : public CBase

Class to store the data that makes up a cookie

Inherits from

Nested Classes and Structures

Public Member Functions
~CCookie()
IMPORT_C voidAddToRequestL(RHTTPHeaders, TInt)
IMPORT_C TIntAttribute(TCookieAttributeName, THTTPHdrVal &)
TInt Attribute(TCookieAttributeName, THTTPHdrVal &, TBool &)
CCookie *CloneL(const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)
voidCopyFromL(const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)
TBool Expired()
TBool FromCookie2()
TBool FromNetscapeVersion()
TBool IsUnknownVersion()
IMPORT_C CCookie *NewL(RHTTPHeaders, TInt, RStringF, RStringPool, const TUriC8 &)
IMPORT_C CCookie *NewL(RStringPool)
TBool Persistent()
voidRemoveAttribute(TCookieAttributeName)
TPtrC8 RemoveQuotes(const TDesC8 &)
IMPORT_C TIntSetAttribute(TCookieAttributeName, const THTTPHdrVal &)
TInt SetAttribute(TCookieAttributeName, const THTTPHdrVal &, TBool)
voidSetCookie2(TBool)
voidSetFromNetscape(TBool)
TInt Size(TBool)
RStringPool StringPool()
Private Member Functions
CCookie(RStringPool)
voidAddDefaultPathL(const TUriC8 &)
voidConstructL(RHTTPHeaders, TInt, RStringF, const TUriC8 &)
TBool ExpiredNetscapeL(THTTPHdrVal)
TInt FindAttribute(TCookieAttributeName, TCookieAttribute &)
TInt FindTokens(const TDesC8 &, const TDesC8 &, const TInt, TInt *)
HBufC8 *GetCleanedDateTimeLC(HBufC8 *)
TInt GetLocalOffset(HBufC8 *, TInt &, TInt &, TInt &)
TInt GetMilitaryOffset(HBufC8 *, TInt &)
TInt GetTimeZone(HBufC8 *, TInt &, TInt &)
voidLog(TInt)
voidRemoveAttribute(TInt)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enumTCookieAttributeName {
EName, EValue, EComment, ECommentURI, EDiscard, EDomain, EMaxAge, EPath, EPort, ESecure, EVersion, EExpires, EDate, ELastAttribute
}
Private Attributes
RArray< TCookieAttribute >iAttributes
TBool iNetscape
TTime iReceivedTime
TBool iSetCookie2
TInt iSize
RStringPool iStringPool

Constructor & Destructor Documentation

CCookie(RStringPool)

CCookie(RStringPoolaStringPool)[private]

Constructor.

Parameters

RStringPool aStringPoolThe current string pool.

~CCookie()

IMPORT_C~CCookie()[virtual]

Standard destructor.

Member Functions Documentation

AddDefaultPathL(const TUriC8 &)

voidAddDefaultPathL(const TUriC8 &aUri)[private]

When the cookie does not have a Path attribute, we have to add a default Path attribute. This method does this addition.

Parameters

const TUriC8 & aUriAn initialized URI parser.

AddToRequestL(RHTTPHeaders, TInt)

IMPORT_C voidAddToRequestL(RHTTPHeadersaRequestHeaders,
TIntaPartIndex
)const

This method writes the cookie (i.e. its attributes) into the specified part of the HTTP header. The method may leave if writing is not successful (e.g. when RHTTPHeaders::SetParamL leaves) or if the cookie is not properly initialized.

Parameters

RHTTPHeaders aRequestHeadersThe current HTTP header collection to which we add this cookie,
TInt aPartIndexThe part of the header.

Attribute(TCookieAttributeName, THTTPHdrVal &)

IMPORT_C TIntAttribute(TCookieAttributeNameaAttributeName,
THTTPHdrVal &aAttributeVal
)const

Attribute retrieves the value of an attribute

Parameters

TCookieAttributeName aAttributeNameIdentifies the attribute
THTTPHdrVal & aAttributeValThe value being retrieved

Attribute(TCookieAttributeName, THTTPHdrVal &, TBool &)

TInt Attribute(TCookieAttributeNameaAttributeName,
THTTPHdrVal &aAttributeVal,
TBool &aDefaulted
)const

Attribute retrieves the value of an attribute

Parameters

TCookieAttributeName aAttributeNameIdentifies the attribute
THTTPHdrVal & aAttributeValThe value being retrieved
TBool & aDefaultedA TBool indicating whether the current attribute's value is defaulted or specified.

CloneL(const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)

CCookie *CloneL(const CCookie &aCopy,
const TDesC8 &aDomain,
const TDesC8 &aPath,
const TDesC8 &aPort
)[static]

Parameters

const CCookie & aCopy
const TDesC8 & aDomain
const TDesC8 & aPath
const TDesC8 & aPort

ConstructL(RHTTPHeaders, TInt, RStringF, const TUriC8 &)

voidConstructL(RHTTPHeadersaRequestHeaders,
TIntaPartIndex,
RStringFaFieldName,
const TUriC8 &aUri
)[private]

Constructor.

Parameters

RHTTPHeaders aRequestHeadersA collection of header fields associated with the current HTTP message,
TInt aPartIndexThe index of the part in the header,
RStringF aFieldNameThe HTTP header name,
const TUriC8 & aUriHTTP request's URI.

CopyFromL(const CCookie &, const TDesC8 &, const TDesC8 &, const TDesC8 &)

voidCopyFromL(const CCookie &aCopyFrom,
const TDesC8 &aDomain,
const TDesC8 &aPath,
const TDesC8 &aPort
)

Copy from an already existing one.

Parameters

const CCookie & aCopyFromThe already existing CCookie object
const TDesC8 & aDomain
const TDesC8 & aPath
const TDesC8 & aPort

Expired()

TBool Expired()const

Returns whether This cookie has expired or not.

ExpiredNetscapeL(THTTPHdrVal)

TBool ExpiredNetscapeL(THTTPHdrValaAttrVal)const [private]

Determines if the cookie had expired in case of Netscape style Method may leave with KErrNoMemory KErrNotFound, if parsing the date string fails (not a well formed string)

Parameters

THTTPHdrVal aAttrValThe THTTPHdrVal holding the Expires date as a string

FindAttribute(TCookieAttributeName, TCookieAttribute &)

TInt FindAttribute(TCookieAttributeNameaAttributeName,
TCookieAttribute &aAttribute
)const [private]

Finds the specified attribute in this cookie

Parameters

TCookieAttributeName aAttributeName
TCookieAttribute & aAttribute

FindTokens(const TDesC8 &, const TDesC8 &, const TInt, TInt *)

TInt FindTokens(const TDesC8 &aString,
const TDesC8 &aTokenSeparators,
const TIntaTokenCount,
TInt *aTokens
)const [private]

Tokenize a string.

Parameters

const TDesC8 & aStringstring to be tokenized
const TDesC8 & aTokenSeparatorsseparator characters
const TInt aTokenCountexpected number of tokens
TInt * aTokensposition of token separators found in aString

FromCookie2()

TBool FromCookie2()const [inline]

Did this cookie come from a SetCookie2 header?

FromNetscapeVersion()

TBool FromNetscapeVersion()const [inline]

Did this cookie come from a Netscape-version header?

GetCleanedDateTimeLC(HBufC8 *)

HBufC8 *GetCleanedDateTimeLC(HBufC8 *aDate)const [private]

Takes an HTTP header date-time information and returnes it in a format supported by TTime.

Parameters

HBufC8 * aDate

GetLocalOffset(HBufC8 *, TInt &, TInt &, TInt &)

TInt GetLocalOffset(HBufC8 *aDate,
TInt &aHour,
TInt &aMinute,
TInt &aLength
)const [private]

Parameters

HBufC8 * aDate
TInt & aHour
TInt & aMinute
TInt & aLength

GetMilitaryOffset(HBufC8 *, TInt &)

TInt GetMilitaryOffset(HBufC8 *aDate,
TInt &aHour
)const [private]

Parameters

HBufC8 * aDate
TInt & aHour

GetTimeZone(HBufC8 *, TInt &, TInt &)

TInt GetTimeZone(HBufC8 *aDate,
TInt &aHour,
TInt &aLength
)const [private]

Parameters

HBufC8 * aDate
TInt & aHour
TInt & aLength

IsUnknownVersion()

TBool IsUnknownVersion()const

Returns whether the cookie's Version attribute is known or not.

Log(TInt)

voidLog(TIntaAssociatedId = 0)const [private]

Parameters

TInt aAssociatedId = 0

NewL(RHTTPHeaders, TInt, RStringF, RStringPool, const TUriC8 &)

IMPORT_C CCookie *NewL(RHTTPHeadersaRequestHeaders,
TIntaPartIndex,
RStringFaFieldName,
RStringPoolaStringPool,
const TUriC8 &aUri
)[static]

Constructor.

Parameters

RHTTPHeaders aRequestHeadersA collection of header fields associated with the current HTTP message,
TInt aPartIndexThe index of the part in the header,
RStringF aFieldNameThe HTTP header name,
RStringPool aStringPoolThe current string pool,
const TUriC8 & aUriHTTP request's URI.

NewL(RStringPool)

IMPORT_C CCookie *NewL(RStringPoolaStringPool)[static]

Constructor.

Parameters

RStringPool aStringPoolThe current string pool.

Persistent()

TBool Persistent()const

Returns whether This cookie is persistent or not.

RemoveAttribute(TCookieAttributeName)

voidRemoveAttribute(TCookieAttributeNameaAttributeName)

Removes a cookie attribute. The attribute is closed, removed from the attribute list and the cookie size is also updated.

Parameters

TCookieAttributeName aAttributeNameidentifies the attribute

RemoveAttribute(TInt)

voidRemoveAttribute(TIntaIndex)[private]

Removes a cookie attribute. The attribute is closed, removed from the attribute list and the cookie size is also updated.

Parameters

TInt aIndexThe position of the cooke attribute in the attribute list.

RemoveQuotes(const TDesC8 &)

TPtrC8 RemoveQuotes(const TDesC8 &aDes)[static]

Returns a descriptor which is equivalent to the input descriptor, but without the surrounding quotation marks. This method always returns the appropriate string even if there are no quotation marks, or at least one of them is missing. This is required because cookie attributes may be surrounded by double quotes.

Parameters

const TDesC8 & aDesThe descriptor to be cleaned.

SetAttribute(TCookieAttributeName, const THTTPHdrVal &)

IMPORT_C TIntSetAttribute(TCookieAttributeNameaAttributeName,
const THTTPHdrVal &aAttributeVal
)

SetAttribute sets an attribute on the cookie. Adding an attribute where one exists will replace the existing one

Parameters

TCookieAttributeName aAttributeNameidentifies the attribute
const THTTPHdrVal & aAttributeValthe value being set

SetAttribute(TCookieAttributeName, const THTTPHdrVal &, TBool)

TInt SetAttribute(TCookieAttributeNameaAttributeName,
const THTTPHdrVal &aAttributeVal,
TBoolaDefaulted
)

SetAttribute sets an attribute on the cookie. Adding an attribute where one exists will replace the existing one

Parameters

TCookieAttributeName aAttributeNameidentifies the attribute
const THTTPHdrVal & aAttributeValthe value being set
TBool aDefaulteda TBool indicating whether it is a defaulted or a supplied value

SetCookie2(TBool)

voidSetCookie2(TBoolaFromCookie2)[inline]

Use this method to specify whether this cookie came from a SetCookie2 header.

Parameters

TBool aFromCookie2ETrue, if the cookie came from a SetCookie2 header, EFalse otherwise.

SetFromNetscape(TBool)

voidSetFromNetscape(TBoolaFromNetscape)[inline]

Use this method to specify whether this cookie is a Netscape style one or an RFC compliant.

Parameters

TBool aFromNetscapeETrue, if the cookie is a Netscape style one, EFalse otherwise.

Size(TBool)

TInt Size(TBoolaSuppressDefaulted)const [inline]

Returns the number of bytes this cookie would require if it was stored in a flat buffer and one attribute followed the other. Note : the attributes are stored in a way that we first write out the size (TInt) of the attribute in question and then the attribute value. E.g. assuming a NAME attribute with the value of SESSIONID, we write out 9 as the length of NAME (again, stored as TInt) and then write out the value of NAME (i.e. SESSIONID).

Parameters

TBool aSuppressDefaultedIf ETrue, the method does not add the size of defaulted attributes to the overall size of the cookie.

StringPool()

RStringPool StringPool()

Returns this cookie's StringPool.

Member Enumerations Documentation

Enum TCookieAttributeName

Enumeration of all the elements of data that make up a cookie

Enumerators

EName
EValue
EComment
ECommentURI
EDiscard
EDomain
EMaxAge
EPath
EPort
ESecure
EVersion
EExpires
EDate
ELastAttribute

Member Data Documentation

RArray< TCookieAttribute > iAttributes

RArray< TCookieAttribute >iAttributes[private]

Array of the attributes of this cookie

TBool iNetscape

TBool iNetscape[private]

Flag indicating whether this cookie is Netscape or RFC compliant It is important to know it as they have different fields, different defaulting and handling.

TTime iReceivedTime

TTime iReceivedTime[private]

TBool iSetCookie2

TBool iSetCookie2[private]

Flag indicating whether this cookie was received in a SetCookie2 header

TInt iSize

TInt iSize[private]

RStringPool iStringPool

RStringPool iStringPool[private]

String pool that can be used by this cookie