Tuesday, 07 April 2026
  2 Replies
  6 Visits
  Subscribe
Hi Sergio, with the latest versions of TsgcWebSocketHTTPServer, files assigned to Contentstream are no longer released. In fact, the DoHTTP2Response function sets the property to nil and doesn't free it.

procedure TsgcWSConnection_Base_HTTP2.DoHTTP2Response(const aRequest
: TIdHTTPRequestInfo; const aResponse: TIdHTTPResponseInfo;
const aLinks: TStrings; aStreamIdentifierRequest: Integer;
aStreamIdentifierPush: Integer = 0);
...
...
...
// ... send data
if not oHeader.EndStream then
begin
oData := HTTP2FrameWrite.Frame_Data;
oData.Clear;
oData.StreamIdentifierRequest := aStreamIdentifierRequest;
oData.StreamIdentifier := oHeader.StreamIdentifier;
oStream := nil;
if aResponse.ContentText <> '' then
oStream := TStringStream.Create(aResponse.ContentText{$IFDEF D2010},
CharsetToCodePage(aResponse.CharSet){$ENDIF})
else if aResponse.ContentStream <> nil then
oStream := aResponse.ContentStream;
Try
oData.SetStream(oStream);
oData.WriteBytes;
Finally
aResponse.ContentStream := nil; <----------------
End;
end;

Consequently, the file remains locked for some functions (rename or delete). Is there a way to have it free the resource instead of setting it to nil?
Alternatively, how can I determine when the handle can be freed?