curl获取header详解

[root@localhost ~]# curl -I https://api.github.com/users/tater/events
HTTP/1.1 200 OK
Date: Thu, 28 Nov 2019 09:05:44 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5
Server: GitHub.com
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1574935544
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "73ca617c70cd2bd9b6f009dab5e2d49d"
X-Poll-Interval: 60
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding
X-GitHub-Request-Id: CDEC:2344:B09B56:DFD245:5DDF8DE8
Header NameDescription
X-RateLimit-LimitThe maximum number of requests you're permitted to make per hour.
X-RateLimit-RemainingThe number of requests remaining in the current rate limit window.
X-RateLimit-ResetThe time at which the current rate limit window resets in UTC epoch seconds.
Cache-Control通用消息头字段,被用于在http请求和响应中,通过指定指令来实现缓存机制。缓存指令是单向的,这意味着在请求中设置的指令,不一定被包含在响应中。
Vary是一个HTTP响应头部信息,它决定了对于未来的一个请求头,应该用一个缓存的回复(response)还是向源服务器请求一个新的回复。它被服务器用来表明在 content negotiation algorithm(内容协商算法)中选择一个资源代表的时候应该使用哪些头部信息(headers).
ETagHTTP响应头是资源的特定版本的标识符。这可以让缓存更高效,并节省带宽,因为如果内容没有改变,Web服务器不需要发送完整的响应。而如果内容发生了变化,使用ETag有助于防止资源的同时更新相互覆盖(“空中碰撞”)。
Access-Control-Expose-Headers列出了哪些首部可以作为响应的一部分暴露给外部。
Access-Control-Allow-Origin响应头指定了该响应的资源是否被允许与给定的origin共享。
HTTP Strict Transport Security通常简称为HSTS)是一个安全功能,它告诉浏览器只能通过HTTPS访问当前资源,而不是HTTP
X-Frame-Options HTTP 响应头是用来给浏览器 指示允许一个页面 可否在 <frame>, <iframe>, <embed> 或者 <object> 中展现的标记。站点可以通过确保网站没有被嵌入到别人的站点里面,从而避免 clickjacking 攻击。
X-Content-Type-Options响应首部相当于一个提示标志,被服务器用来提示客户端一定要遵循在 Content-Type 首部中对 MIME 类型 的设定,而不能对其进行修改。这就禁用了客户端的 MIME 类型嗅探行为,换句话说,也就是意味着网站管理员确定自己的设置没有问题。

我执行了几次,X-RateLimit-Remaining数量从60逐渐减少到57.

[root@localhost ~]# curl -I https://api.github.com/users/tater/events
HTTP/1.1 200 OK
Date: Thu, 28 Nov 2019 09:10:40 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5
Server: GitHub.com
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1574935840
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "73ca617c70cd2bd9b6f009dab5e2d49d"
X-Poll-Interval: 60
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding
X-GitHub-Request-Id: CE2A:0F28:AECE1C:DFEDE4:5DDF8F10

[root@localhost ~]# curl -I https://api.github.com/users/tater/events
curl: (7) Failed connect to api.github.com:443; Connection timed out
[root@localhost ~]# curl -I https://api.github.com/users/tater/events
HTTP/1.1 200 OK
Date: Thu, 28 Nov 2019 09:10:58 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5
Server: GitHub.com
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1574935840
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "73ca617c70cd2bd9b6f009dab5e2d49d"
X-Poll-Interval: 60
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding
X-GitHub-Request-Id: CE2E:0F27:5B7DD2:761901:5DDF8F22

[root@localhost ~]# curl -I https://api.github.com/users/tater/events
curl: (7) Failed connect to api.github.com:443; Connection timed out
[root@localhost ~]# curl -I https://api.github.com/users/tater/events
curl: (7) Failed connect to api.github.com:443; Connection timed out
[root@localhost ~]# curl -I https://api.github.com/users/tater/events
curl: (7) Failed connect to api.github.com:443; Connection timed out
[root@localhost ~]# curl -I https://api.github.com/users/tater/events

curl: (7) Failed connect to api.github.com:443; Connection timed out
[root@localhost ~]# 
[root@localhost ~]# curl -I https://api.github.com/users/tater/events
curl: (7) Failed connect to api.github.com:443; Connection timed out
[root@localhost ~]# curl -I https://api.github.com/users/tater/events
HTTP/1.1 200 OK
Date: Thu, 28 Nov 2019 09:12:00 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5
Server: GitHub.com
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1574935920
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "73ca617c70cd2bd9b6f009dab5e2d49d"
X-Poll-Interval: 60
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding
X-GitHub-Request-Id: CE35:0F27:5B86E0:762509:5DDF8F60
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

少陽君

谢谢老板的拿铁

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值