Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: TidCookieManager questions (threads)

www.cryer.info
Managed Newsgroup Archive

Re: TidCookieManager questions (threads)

Subject:Re: TidCookieManager questions (threads)
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Thu, 22 Mar 2007 10:38:58

"dk_sz" <dk_sz@hotmail.com> wrote in message
news:46027df1$1@newsgroups.borland.com...

> I suspect some data gets messed up, perhaps related to:
> It seems like all access to raw TidCookies collection
> data is not threadsafe (e.g. Items, Cookie) as opposed to
> *LockCookieListByDomain / FCookieListByDomain*

It is not thread-safe at all.  You will have to maintain a separate
copy of the cookies, such as with a global TIdCookieManager that is
not directly assigned to any TIdHTTP objects, and then copy the
individual cookies to/from each TIdHTTP instance when needed.  That
way, you can protect all access to the shared TIdCookieManager, and
each TIdHTTP can operate on a local copy of the cookies without
effecting other instances, ie:

    IdHTTP.CookieManager.CookieCollection.Clear;
    // copy shared cookies into TIdHTTP, then...
    IdHTTP1.Get(...);
    // now copy the new cookies into the shared manager as needed...


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive