curl - 如何使用命令行curl显示请求 header

标签 curl

命令行curl可以使用-D选项显示响应 header ,但我想查看它发送的请求 header 。我怎样才能做到这一点?

最佳答案

curl 的 -v--verbose 选项显示 HTTP 请求 header 等。以下是一些示例输出:

$ curl -v http://google.com/
* About to connect() to google.com port 80 (#0)
*   Trying 66.102.7.104... connected
* Connected to google.com (66.102.7.104) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.16.4 (i386-apple-darwin9.0) libcurl/7.16.4 OpenSSL/0.9.7l zlib/1.2.3
> Host: google.com
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Thu, 15 Jul 2010 06:06:52 GMT
< Expires: Sat, 14 Aug 2010 06:06:52 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 1; mode=block
< 
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
* Connection #0 to host google.com left intact
* Closing connection #0

关于curl - 如何使用命令行curl显示请求 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3252851/

相关文章:

php - 服务器端的 CURL HTTP 身份验证

debugging - CURLE_RECV_ERROR 与 PayPal API

json - 如何从 GitHub 克隆所有 repos(包括私有(private) repos)?

linux - 如何使用 curl 将文件从一台服务器流式传输到另一台服务器(有限的服务器资源)

php - 代理后面的 curl 发布文件返回错误

php - 使用 cURL 通过 javascript 抓取网站

python - 提交文件时python curl的问题

php - Curl 以空字符串响应。如何获取更多信息?

php - cURL 函数无响应

http - 可以使用 curl 来模拟持久(但空闲)的打开连接