curl 显示 HTTP header 档头


curl 是 CLI 下的浏览器, 有时在 Linux 需要对网页进行除错时, 只需要检视 HTTP 的 header 档头资讯, 可以透过 curl 的 -I 参数取得, 例如:

$ curl -I https://google.com.hk
HTTP/1.1 301 Moved Permanently
Location: https://www.google.com.hk/
Content-Type: text/html; charset=UTF-8
Date: Wed, 09 Jan 2019 01:39:03 GMT
Expires: Fri, 08 Feb 2019 01:39:03 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 223
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alt-Svc: quic=”:443″; ma=2592000; v=”44,43,39,35″

可以看到上面的回传结果, 存取 https://google.com.hk 时会, 会用 301 导向到 https://www.google.com.hk/ .

Leave a Reply