Indy 9 | Content | Index | Reference

TIdCookies
Hierarchy, Properties, Methods, See Also, Unit: IdCookie
Implements a container for Cookie class instances.

    TIdCookies = class(TOwnedCollection)

Unit
IdCookie
Description
TIdCookies is a TOwnedCollection descendant that implements a container for Cookie class instances. TIdCookies provides methods that allow creation of both TIdCookieRFC2109 and TIdCookieRFC2965 Cookie class instances. TIdCookies also provides methods that provide access to Cookie class instances using Cookie name, Cookie name and Domain, and an integer position in the Cookie collection.

TIdCookies is the type used by TIdCookieManager to represent the Cookie collection maintained by a TIdHTTP client.

TIdCookies.Cookie
TIdCookies, See Also
Provides access to Cookie collection items using name and domain values.

    property Cookie [const AName, ADomain: string]: TIdCookieRFC2109;

Return Value
TIdCookieRFC2109 - Cookie with the specified name and domain, or Nil.
Description
Cookie is a read-only TIdCookieRFC2109 property that provides access to Cookies in the collection using the name and domain specified in AName and ADomain. TIdCookies calls GetCookieIndex, when using the read access specifier for Cookie, to determine the position of the Cookie having the specified CookieName and Domain. Cookie can return Nil when a Cookie cannot be located in the collection having the specified name and domain values.

Use CookieListByDomain to limit access to Cookie collection items having a specified Domain value. Use Items to access Cookie collection items by their integer position in the container.

TIdCookies.Items
TIdCookies, See Also
Provides access to Cookie collection items by position in the container.

    property Items [Index: Integer]: TIdCookieRFC2109;

Parameters
Index
Position in the container to be accessed.
Return Value
TIdCookieRFC2109 - Cookie at the specified position in the collection.
Description
Items is a TIdCookieRFC2109 property that provides access to Cookie class instances in the collection using the Integer position specified in Index. Items is the default property used when accessing the collection.

Items is used when accessing or updating Cookie collection items in the GetCookie, GetCookieIndex, and Delete methods.

TIdCookies.Add
TIdCookies, See Also
Creates a Cookie class instance to be added to the Cookie collection.

    function Add: TIdCookieRFC2109;

Return Value
TIdCookieRFC2109 - Cookie class instance added to the collection.
Description
Add is a TIdCookieRFC2109 function that creates a new instance of TIdCookieRFC2109 to be added to the Cookie collection. Add creates the Cookie class instance using the TIdCookies object instance as the owner of the collection item.

Add is called from the TIdCookieManager.AddCookie method when a CookieName and Domain are added to an HTTP client as an TIdCookieRFC2109 class instance.

TIdCookies.Add2
TIdCookies, See Also
Creates a Cookie class instance to be added to the Cookie collection.

    function Add2: TIdCookieRFC2965;

Return Value
TIdCookieRFC2965 - Cookie class instance added to the collection.
Description
Add2 is a TIdCookieRFC2965 function that creates a new instance of TIdCookieRFC2965 to be added to the Cookie collection. Add creates the Cookie class instance using the TIdCookies object instance as the owner of the collection item.

Add2 is called from the TIdCookieManager.AddCookie2 method when a CookieName and Domain are added to an HTTP client as an TIdCookieRFC2965 class instance.

TIdCookies.AddCookie
TIdCookies, See Also
Adds or updates a Cookie instance in the collection.

    procedure AddCookie(ACookie: TIdCookieRFC2109);

Parameters
ACookie: TIdCookieRFC2109
Cookie class instance to be added or updated in the collection.
Description
AddCookie is a procedure that adds a TIdCookieRFC2109 class instance specified in ACookie to the Cookie collection. AddCookie uses an instance of TIdCookieList to maintain a list of Cookies for the Domain specified in ACookie. AddCookie also uses CookieListByDomain to create or maintain Cookie class instances using the value of CookieName specified in ACookie.

If a Cookie having the Domain and CookieName specified in ACookie already exists in the collection, the Cookie value is assigned to the existing TIdCookieRFC2109 object instance and ACookie is freed. Otherwise, ACookie is added to the Cookie list for the specified Domain and CookieName.

AddCookie is called by TIdCookieManager when a Cookie is added to the collection maintained by an HTTP client.

TIdCookies.AddSrcCookie
TIdCookies, See Also
Creates a new Cookie collection item using the textual Cookie data.

    procedure AddSrcCookie(const sCookie: string);

Parameters
const sCookie: string
Textual representation of the Cookie.
Description
AddSrcCookie is a procedure used to create a new Cookie class instance in the collection using the textual representation of Cookie specified in sCookie. AddSrcCookie calls Add to create the Cookie class instance added to the collection. AddSrcCookie sets the name, value, and attributes for the Cookie by updating CookieText to reflect the data specified in sCookie.

TIdCookies.Create
TIdCookies, See Also
Constructor for the object instance.

    constructor Create(AOwner: TPersistent);

Parameters
AOwner: TPersistent
Owner of the collection.
Description
Create is the constructor for the object instance. Create calls the inherited Create method using AOwner as the owner of the collection, and TIdCookieRFC2109 as the ItemClass maintained in the collection.

Create initializes the TIdCookieList used by the CookieListByDomain property, and sets Sorted to False in the object property. Create also allocates an internal TMultiReadExclusiveWriteSynchronizer instance that is used to protect access to the collection in a multi-threaded application.

TIdCookies.Delete
TIdCookies, See Also
Removes a Cookie from the collection.

    procedure Delete(Index: Integer);

Parameters
Index: Integer
Position of the Cookie in the container.
Description
Delete is a procedure that allows freeing of a Cookie class instance in the collection by the Integer position in the container specified in Index. Delete accesses the collection using the Items property and the specified Index position to call the Free method for the collection item.

TIdCookies.Destroy
TIdCookies, See Also
Frees the object instance.

    destructor Destroy; override;

Description
Destroy is the destructor for the object instance. Destroy calls Clear to insure that Cookies are removed from the collection. Destroy frees resources allocated in the Create constructor, including the CookieListByDomain property and the internal protection mechanism used to access the collection. Destroy calls the inherited Destroy method prior to exiting.

TIdCookies.GetCookieIndex
TIdCookies, See Also
Indicates the index position of a Cookie containing specified values.

    function GetCookieIndex(FirstIndex: integer; const AName: string): Integer; overload;
    function GetCookieIndex(FirstIndex: integer; const AName: string; const ADomain: string): Integer; overload;

Parameters
FirstIndex: integer
Initial position to be examined in the collection.
const AName: string
Cookie name to be matched.
const ADomain: string
Domain attribute to be matched.
Return Value
Integer - Position of the matched Cookie in the collection, or -1 when not found.
Description
GetCookieIndex is an overloaded Integer function that accesses Cookie class instances in the collection to determine the position of the collection item matching the specified search criteria. GetCookieIndex will return the value -1 when a Cookie cannot be located in the collection that matches the specified search criteria.

FirstIndex specifies the initial position in the container to be used when comparing values in the AName and/or ADomain parameters.

AName is the CookieName value desired in a Cookie collection item.

ADomain is the Domain value desired in a Cookie collection item.

GetCookieIndex is called from the GetCookie method to locate one of the Items in the collection that match a specified Name and Domain.

TIdCookies.GetCookieIndex
TIdCookies, See Also
Indicates the index position of a Cookie containing specified values.

    function GetCookieIndex(FirstIndex: integer; const AName: string): Integer; overload;
    function GetCookieIndex(FirstIndex: integer; const AName: string; const ADomain: string): Integer; overload;

Parameters
FirstIndex: integer
Initial position to be examined in the collection.
const AName: string
Cookie name to be matched.
const ADomain: string
Domain attribute to be matched.
Return Value
Integer - Position of the matched Cookie in the collection, or -1 when not found.
Description
GetCookieIndex is an overloaded Integer function that accesses Cookie class instances in the collection to determine the position of the collection item matching the specified search criteria. GetCookieIndex will return the value -1 when a Cookie cannot be located in the collection that matches the specified search criteria.

FirstIndex specifies the initial position in the container to be used when comparing values in the AName and/or ADomain parameters.

AName is the CookieName value desired in a Cookie collection item.

ADomain is the Domain value desired in a Cookie collection item.

GetCookieIndex is called from the GetCookie method to locate one of the Items in the collection that match a specified Name and Domain.

TIdCookies.LockCookieListByDomain
TIdCookies, See Also
Provides resource protection for write access to Cookies in the Cookie collection.

    function LockCookieListByDomain(AAccessType: TIdCookieAccess): TIdCookieList;

Parameters
AAccessType: TIdCookieAccess
Access requested for the resource protection block.
Return Value
TIdCookieList - List of Cookies for the specified Domain.
Description
LockCookieListByDomain is a TIdCookieList function that protects write access to resources in the Cookie collection for the using a TMultiReadExclusiveWriteSynchronizer. AAccessType is a TIdCookieAccess value that indicates the access type that should be recorded using the resource protection lock.

The return value for LockCookieListByDomain is the values returned by the CookieListByDomain method call.

LockCookieListByDomain is used by method that create or free items in the Cookie collection, like Add and Delete.

TIdCookies.UnlockCookieListByDomain
TIdCookies, See Also
Releases resource protection for accessing Cookies in the Cookie collection.

    procedure UnlockCookieListByDomain(AAccessType: TIdCookieAccess);

Parameters
AAccessType: TIdCookieAccess
Access requested for the resource protection block.
Description
UnlockCookieListByDomain is a procedure that releases the resource protection block for the Cookie collection created using LockCookieListByDomain. AAccessType is a TIdCookieAccess value that indicates the access type that should be released for the resource protection block.

UnlockCookieListByDomain is used by methods that create or free items in the Cookie collection, like Add and Delete.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.