New version is up:
- Changed socket_change() timeout from default of 100000 to 0 to avoid blocking.
- Added file size to download progress forward.
- Added FTP_AbortTransfer() function to stop a current file transfer.
- Fixed bug where if an error occurred opening\creating the local file the download would still proceed. Reported by dummy82.
For what you're trying to do drekes, I did not want to add a function that solely retrieved file-size because it would be a lot of redundant code. What you can do instead is start a transfer and on the first forward call you can compare existing size to new size and abort transfer if same, like in the example below. I have not thoroughly tested a lot of files to see if 'Content-Size' is always included in the http header, if it's not included then file-size will just be 0 in the forward.
new const Version = "0.1";
new g_CurrentSize = 5242880;
register_plugin( "HTTP Test" , Version , "bugsy" );
register_concmd( "test" , "DownloadFile" );
HTTP_DownloadFile( "http://download.thinkbroadband.com/5MB.zip" , "ZIP.ZIP" );
public HTTP_Download( const szFile , iDownloadID , iBytesRecv , iFileSize , bool:TransferComplete )
if ( iFileSize == g_CurrentSize )
server_print( "No change in file size" );
HTTP_AbortTransfer( iDownloadID );
if ( TransferComplete )
server_print( "%s download complete!" , szFile );
server_print( "File=[%s] DownloadID=%d BytesTransferred=%d Size=%d" , szFile , iDownloadID , iBytesRecv , iFileSize );