download manager

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

download manager

Geoffray Levasseur
Hello everybody,

I'm currently trying to create a download manager with Synapse for an
application I'm creating. As the application may need to download many big
files from either ftp or http servers (it's a Linux package manager and a
graphical installer for a distribution I'm creating with friends), I need to
give good informations about download progress. The idea is to first get total
size of the files to download (URL will be in a string list) then really
downloads it (several downloads at a time if different servers/mirrors). The
TDownloadManager class I'm creating will deal with that automatically using
Threads.

With HTTP my problem is that I can't find the way to get the size of the file
on the server while HTTPSend.DownloadSize is giving me the size of what have
been downloaded.

Oppositely with FTP TFTPSend.GetFileSize is supposed to give me the total size
of the file but I can't find the way to get the downloaded size to give
progress.

Thank you very much for any help.
--
Geoffray Levasseur-Brandin <[hidden email]>
http://jeff.levasseur.tuxfamily.org/
GNU/PG : BF8BB8407CD26E89466CDA9BB1030FC59EF87775
Errare humanum est sed perseverare diabolicum aut cretinum.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

signature.asc (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: download manager

Lukas Gebauer
> With HTTP my problem is that I can't find the way to get the size of the
> file on the server while HTTPSend.DownloadSize is giving me the size of
> what have been downloaded.

HTTP have a few ways how to download data. But not all ways know size of
data. For example, in chunked way you know size of next chunk only.
Remember your favourite web browser - sometimes it dowloading file, even
it does not shot full file size! Here it is same!

If filesize or at least next chuk size is known, then it is in
DownloadedSize property. It is designed for progress indicators.

However if you wish to know size of file o the server, try to ask you
HTTP server by HEAD method (instead of GIT) and analyze
THTTTPSend.Headers. See the Content-Length header.


--
Lukas Gebauer.

http://synapse.ararat.cz/ - Synapse Delphi and Kylix TCP/IP Library
http://geoget.ararat.cz/ - Geocaching solution


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal