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

电脑知识 投稿 27200 0 评论

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

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

主要有两种方式:

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


[demo@Linux ~]$ curl --head https://www.feishuai.vip/

curl --head www.feishuai.vip
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.feishuai.vip/

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


[demo@Linux ~]$ curl -i https://www.feishuai.vip/

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.feishuai.vip/

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

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

赞同 (113) or 分享 (0)
游客 发表我的评论   换个身份
取消评论

表情
(0)个小伙伴在吐槽