ScHttpServer and ResponseInfo.OutputStream
I would like to know what is the best way to use the ScHttpServer component to return an Outputstream.
I have the following code in ScHttpServerProcessRequest, and it works, but when I release the stream, it stops working.
try
fs := TFileStream.Create( vFilename , fmOpenRead OR fmShareDenyNone);
fs.Position := fs.Size;
ResponseInfo.ContentType := 'application/*';
ResponseInfo.ContentLength := fs.Size;
ResponseInfo.SendChunked := True;
ResponseInfo.OutputStream:=fs;
ResponseInfo.StatusCode := scAccepted;
finally
//fs.Free; <----if uncomment error: You must write ContentLength bytes to OutputText or OutputStream
end;
Obtain "You must write ContentLength bytes to OutputText or OutputStream"