且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过HTTP获取远程文件大小,而无需下载该文件

更新时间:2023-09-26 21:23:22

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

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