linux curl获取头部信息,curl 命令如何获取 http header 返回的响应消息头

 
更多

curl 命令如何获取 http 请求的响应消息头信息?

主要有两种方式:

(1) 通过 –head 选项只返回消息头,等价于 -I,示例如下:

[demo@Linux ~]$ curl --head http://www.phpernote.com/

curl –head www.phpernote.com
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 03 Nov 2021 07:18:26 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://www.phpernote.com/

(2) 通过 -i 选项返回包含 header 内容的所有网页实体 body 信息,示例如下:

[demo@Linux ~]$ curl -i http://www.phpernote.com/

HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 03 Nov 2021 07:22:15 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://www.phpernote.com/

<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

打赏

本文固定链接: https://www.cxy163.net/archives/3166 | 绝缘体

该日志由 绝缘体.. 于 2021年11月01日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: linux curl获取头部信息,curl 命令如何获取 http header 返回的响应消息头 | 绝缘体
关键字: , , , ,

linux curl获取头部信息,curl 命令如何获取 http header 返回的响应消息头:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter