【发布时间】:2021-12-31 21:00:33
【问题描述】:
对于我的研究,我需要卷曲 fqdns 并获取它们的状态代码。 (对于 Http、Https 服务)但是一些 http url 以 https 打开,尽管它使用 cURL 返回 200。 (请求成功,没有重定向)
curl -I http://example.example.com/
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 22 Nov 2021 10:43:32 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 64991
Connection: keep-alive
Keep-Alive: timeout=20
Vary: Accept-Encoding
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Link: <https://example.example.com/>; rel=shortlink
X-Powered-By: WP Engine
X-Cacheable: SHORT
Vary: Accept-Encoding,Cookie
Cache-Control: max-age=600, must-revalidate
X-Cache: HIT: 10
X-Cache-Group: normal
Accept-Ranges: bytes
如上所示,我收到了 curl 请求的 200 响应。但我可以在浏览器中看到 307 代码。 (见下图)
Request URL: http://example.example.com/
Request Method: GET
Status Code: 307 Internal Redirect
Referrer Policy: strict-origin-when-cross-origin
我可以用 curl 检测 307 代码吗? (-L参数不起作用)有什么建议吗?
【问题讨论】:
-
您是在寻找终端命令,还是脚本有效?
-
感谢您的回复。只有终端命令。但结果,我会把它做成一个python脚本。
-
-L选项告诉 cURL 自动跟随重定向。所以,删除这个选项并抓住response_code -
一个可能的区别是大多数浏览器在请求期间发送的标头“Upgrade-Insecure-Requests”。这可能会导致内部重定向到 https。
-
在浏览器中打开开发工具。单击网络选项卡。转到网址。查看浏览器发送的标头。重复 curl 命令添加所有标题。现在还一样吗?
标签: http curl https httpresponse