问题
Any way to get the size of a (remote, http) file without actually downloading it?
All other similar questions seem to revolve around grabbing the expectedContentLength
from the NSURLResponse
object in didReceiveResponse:
but I don't want to download the file, I just want to know how big it is.
回答1:
Try to make HEAD request, it returns only headers with Content-Length header included.
~$ curl -I http://google.com/
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Length: 219
...
来源:https://stackoverflow.com/questions/3397454/get-remote-file-size-via-http-without-downloading-said-file