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?
david_nAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sreenathkCommented:
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.

Sreenath
0
wildyCommented:
----Header Sent----
GET /pippo.zip HTTP/1.1
Host: www.pluto.com
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 (http://www.w3.org/Protocols/rfc2616/rfc2616.txt)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.