File size to download

My application downloads file using HTTP protocol from a WebServer. If there is a way to determine size of the file before downloading?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

wildyConnect With a Mentor Commented:
----Header Sent----
GET / HTTP/1.1
Range: bytes=0-
User-Agent: GetRight/4.1.2
Accept: *.*, */*

----Header Recv----
HTTP/1.1 206 Partial content
Server: Microsoft-IIS/4.0
Date: Thu, 03 Feb 2000 20:05:29 GMT
Content-Type: application/x-gzip
Last-Modified: Thu, 03 Feb 2000 02:36:02 GMT
ETag: "deb6ba69ef6dbf1:4894"
Content-Length: 3534848
Content-Range: bytes 0-3534847/3534848

If u look at this, you see a "Content-Length" tag: this is the file length.

For more info look at RFC2616 (
I do not think there is a function to know the file size using http protocl. Instaead there is a work around, first open a ftp session using ftp protocol and get the file size using function size. Then close the session and open a http session and download as many bytes of http file. But this is going to waste bandwidth little. If it a must to get file size, then I think this is the one way.

All Courses

From novice to tech pro — start learning today.