如何从 Windows 命令行执行 HTTP HEAD 请求?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/217955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to do a HTTP HEAD request from the windows command line?
提问by Henning
What's the best way (or tool) on the Windows (Vista) command line to get size and modification time for a file on a remote webserver, without downloading it?
Windows (Vista) 命令行上无需下载即可获取远程 Web 服务器上文件的大小和修改时间的最佳方法(或工具)是什么?
采纳答案by CesarB
On Linux, I often use curl with the --head parameter. It is available for several operating systems, including Windows.
在 Linux 上,我经常使用带有 --head 参数的 curl。它适用于多种操作系统,包括 Windows。
[edit] related to the answer below, gknw.net is currently down as of February 23 2012. Check curl.haxx.se for updated info.
[编辑] 与下面的答案相关,gknw.net 目前在 2012 年 2 月 23 日关闭。检查 curl.haxx.se 以获取更新信息。
回答by Tomalak
There is a Win32 port of wgetthat works decently.
PowerShell's Invoke-WebRequest -Method Head
would work as well.
PowerShellInvoke-WebRequest -Method Head
也能工作。
回答by Laurence
If you cannot install aditional applications, then you can telnet (you will need to install this feature for your windows 7 by following this) the remote server:
如果您无法安装aditional的应用程序,那么你就可以远程登录(你需要通过以下步骤来安装此功能,您的Windows 7这个)的远程服务器:
TELNET server_name 80
followed by:
其次是:
HEAD /virtual/directory/file.ext
or
或者
GET /virtual/directory/file.ext
depending on if you want just the header (HEAD) or the full contents (GET)
取决于您是只想要标题(HEAD)还是完整的内容(GET)
回答by David Bell
1) See the headers that come back from a GET request
1) 查看从 GET 请求返回的标头
wget --server-response -O /dev/null http://....
1a) Save the headers that come back from a GET request
1a) 保存从 GET 请求返回的标头
wget --server-response -o headers -O /dev/null http://....
2) See the headers that come back from GET HEAD request
2) 查看从 GET HEAD 请求返回的标头
wget --server-response --spider http://....
2a) Save the headers that come back from a GET HEAD request
2a) 保存从 GET HEAD 请求返回的标头
wget --server-response --spider -o headers http://....
- David
- 大卫