Clément 148 Posted August 25 (edited) Hello, I'm using 8.69, I can't update right now, and Delphi 12.1. I wrote a TUrlHandle child class to handle download of binary files. In this case zrnbw file. I'm unable to figure out how to do it. I'm missing a lot of things. With this code, any client application that connects to my appServer hangs after sending the download request. How would be the right way to handle downloading of binary data? TIA procedure THandler_files_UpdateDownload.Execute; const NO_CACHE: String = 'Pragma: no-cache' + #13#10 + 'Expires: -1' + #13#10; begin inherited; var lBasename : String; var lZrnbwFile := ''; var lParams := TStringList.Create('"', '&', [soStrictDelimiter]); try lParams.DelimitedText := Client.Params; lBaseName := TNetEncoding.URL.Decode( lParams.Values['basename'] ); lZrnbwFile := TPath.Combine( glbServerConfig.DefaultUpdate, lBasename+'.zrnbw'); if FileExists(lZrnbwFile) then begin DocStream := TFileStream.Create( lZrnbwFile, fmOpenRead ); AnswerStream('','application/binary',NO_CACHE); //Client.DocStream.Free; end finally lParams.free; end; end; Edited August 25 by Clément Share this post Link to post
Angus Robertson 574 Posted August 25 Essentially your code is ok, except the first parameter of AnswerStream is var Flags : THttpGetFlag; so can not be left blank. There is a an extra parameter to pass a last modified date which is friendly for so applications that do a HEAD first to check if the file is newer. You should free DocStream before creating it, and the server should free it when the request completes. Angus Share this post Link to post