On 2014-07-03 17:20:53 -0300, silvioprog wrote: > 2014-07-03 16:51 GMT-03:00 Leonardo M. Ramé <l.r...@griensu.com>: > > > Hi, I have a CGI program that serves some files using this code in an > > action: > > > > AResponse.ContentStream := TFileStream.Create(lImagePath, fmOpenRead); > > > > The problem I'm facing is that some times the client breaks the > > connection to the server, aparently leaving the file open. If the client > > tries to download the file again, a code 500 is returned. > > > > Is there a way to detect the connection break and destroy the stream > > gracefully?. > > > > You can use the FreeContentStream property and free your stream manually, > e.g.: > > var > f: TFileStream; > begin > f := TFileStream.Create(...); > try > HttpResponse.FreeContentStream := False; > HttpResponse.ContentType := 'application/octet-stream'; > HttpResponse.ContentStream := f; > HttpResponse.SendContent; > finally > f.Free; > end; > end; >
Thanks Silvio, it seems to work. -- Leonardo M. Ramé http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus