After the stream has been passed to CommandGet, when can it be freed?

with indy TIdHTTPServer, on an even OnCommandGet, it is possible to transmit an AResponseInfo.ContentStream data stream. what well. when can i free this thread? assuming that the server can receive several requests, and any request can be processed at a given time, and one thread can execute arbitrary for another.

where can the thread be freed?

Code example

:

var StreamsToFree : TList; //assume StreamsToFree := TList.create; properly procedure TObject.IdHttpServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); var stream : TFileStream; begin stream := TFileSTream.create('file.name'); AResponseInfo.ContentStream := stream; AResponseInfo.ResponseNo := 200; StreamsToFree.Add(generateReceiptXML); end; 

When can a thread be freed? what even, and how do we know IdHttpServer, completed its transfer?

+8
memory-management stream delphi delphi-2009 indy
source share
1 answer

When you assign it to the ContentStream property, Indy becomes the owner of your stream and frees it when it is no longer needed.

Edit: suppose you leave the FreeContentStream property FreeContentStream to True (default).

+14
source share

All Articles