我有以下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
我收到以下回复
<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>
嗯,我怎么检查实际的http代码,它是一个302 curl文档声称他们遵循redirect,所以我不知道是怎么回事?
谢谢,Dean
嗯,也许这是一个错误,在curl不跟随HTTPredirect浏览器如https? 我的问题是简单地说,负载平衡器总是redirect到https,我在那里有http …这么奇怪,这将是一个更好的错误,因为它不会redirect到https(即。不像文档状态那样遵循所有redirect)。
通过-L cURL ,它将遵循302。
添加-v来curl以查看实际的标题响应。
默认情况下,它不遵循redirect,添加-L也遵循redirect,但(从手册页):
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.