我有以下 curl 命令
curl -X POST -w "\nRESULT CODE:%{http_code}\n" --insecure --header "Content-Type:application/json" --user robot-midc:1ZSXM7 -d @table.json http://databus.nrel.gov/api/registerV1
Run Code Online (Sandbox Code Playgroud)
我收到以下回复
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.2.4</center>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
嗯,我如何检查实际的 http 代码,它是 302,因为 curl 文档声称他们遵循重定向,所以我不确定发生了什么?
谢谢,院长
嗯,也许这是一个错误,因为 curl 不像浏览器那样遵循 http 到 https 重定向????我的问题很简单,负载均衡器总是重定向到 https 并且我在那里有 http 在线......太奇怪了,curl 给出更好的错误会很好,因为它不会重定向到 https(即。不遵循文档所述的所有重定向)。
添加-v到 curl 以查看实际的标头响应。
默认情况下,它不遵循重定向,添加-L也遵循重定向,但是(来自手册页):
When authentication is used, curl only sends its credentials to the
initial host. If a redirect takes curl to a different host, it
won't be able to intercept the user+password. See also --location-trusted
on how to change this.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10447 次 |
| 最近记录: |