Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Re: CookieManager thread safety
| Subject: | Re: CookieManager thread safety |
| Posted by: | "dk_sz" (dk_..@hotmail.com) |
| Date: | Mon, 8 May 2006 12:26:23 |
> free / notification system isn't thread safe is it?
> Is this already solved in snapshot or...?
Well, here is a temporary solution that
does not require eiditng the Indy files.
Anyway, as many people use http connections in threads
(and thus may often require to share the cookiemanager),
well... Other people should also be experiencing the (IMHO) bug?
type
TmsHttp = class(TidHttp)
protected
procedure SetCookieManager(ACookieManager: TIdCookieManager);
public
property CookieManager: TIdCookieManager read FCookieManager write
SetCookieManager;
end;
//------------------------------------------------------------------------------
procedure TmsHttp.SetCookieManager(ACookieManager: TIdCookieManager);
begin
{
This class assumes that if *CookieManager* is set from outside, then
cookiemanager "lifetime" will also be wrapped around the HTTP object.
By cutting the "notification" system we avoid thread unsafe code.
}
if Assigned(FCookieManager) = False then
begin
FCookieManager := ACookieManager;
end
else
begin
// cookie has already been set once (e.g. by *ProcessCookies*)...
end
;
end;
best regards
Thomas Schulz