Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it at all possible to get the size of a remote file without downloading it? The file is over HTTP, not (S)FTP. I want to know this because I want to download something while connected with a limited 3G wireless plan and I don't want to use all my bandwidth in one pop. I have no access to the server, at all. So I can't do anything server-side. I am on Mac OS X. Solutions that make use of the command line are a plus, but not required.

By the way, the specific file I want information for is the MP3 download from this website.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

You can do this by getting the Content-Length header, so long as it is HTTP.

One way of doing this on the command line is with curl, for example:

chris@chris-laptop:~$ curl -I -L http://www.fakkelbrigade.eu/chris/movies/drosovol1_final_h264_download.mp4
HTTP/1.1 200 OK
Date: Tue, 25 Jan 2011 22:22:51 GMT
Server: Apache/2.2.16 (Debian)
Last-Modified: Tue, 11 Jan 2011 16:32:52 GMT
ETag: "3aa003-1b0c3479-49994a2c6f500"
Accept-Ranges: bytes
Content-Length: 453784697
Content-Disposition: attachment
Content-Type: application/octet-stream

Content-Length is in bytes.

share|improve this answer
    
Awesome! Thank you! –  Wuffers Jan 25 '11 at 22:27
    
No problem! Glad you found a solution :) –  Matthieu Cartier Jan 25 '11 at 22:28
1  
addons.mozilla.org/en-us/firefox/addon/live-http-headers There's also this addon that would help if you are a firefox user. –  Jeshii Jan 25 '11 at 22:52

You can issue HTTP HEAD requests to get the only header data. Content-Length is what you want.

$ telnet superuser.com 80
Trying 64.34.119.12...
Connected to superuser.com.
Escape character is '^]'.
HEAD / HTTP/1.0

HTTP/1.1 302 Found
Content-Length: 141
Location: http://stackexchange.com
Date: Tue, 25 Jan 2011 22:21:28 GMT
Connection: close
share|improve this answer

It depends on how the server is setup and the file. With most files the server sends it in the headers, but it may be a dynamic file and therefore it doesn't know (and your browser can't guess how long it will take.

tobylane$ telnet stackexchange.com 80

Trying 64.34.119.12...

Connected to stackexchange.com.

Escape character is '^]'.

GET /

HTTP/1.1 302 Found

Location: http://stackexchange.com

Date: Tue, 25 Jan 2011 22:01:22 GMT

Connection: close

I'm not sure what a good request is (GET / worked on other sites), but I hope this helps.

share|improve this answer
1  
What "other sites" did it work for? It would be more helpful if you would post the ones it worked for instead of one it didn't work for. –  Wuffers Jan 25 '11 at 22:06
    
Also, just a tip. You can indent code/console output like that by four spaces to make it preformatted and a lot more readable. –  Wuffers Jan 25 '11 at 22:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.