通过HTTP获取远程文件大小而不下载所述文件

时间:2010-08-03 14:24:55

标签: iphone web-services file nsurlconnection nsurlrequest

任何方法来获取(远程,http)文件的大小而不实际下载它?

所有其他类似的问题似乎都围绕着从expectedContentLength中的NSURLResponse对象抓取didReceiveResponse:,但我不想下载文件,我只是想知道有多大它是。

1 个答案:

答案 0 :(得分:2)

尝试发出HEAD请求,它只返回包含Content-Length标头的标头。

~$ curl -I http://google.com/
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Length: 219
...
相关问题