接口调不通,用 curl -v 逐步看请求头、响应码和耗时

接口不通时 curl -v 会把请求头、响应码和 TLS 握手全过程打出来。

看 > 开头的是发出的请求,< 开头的是响应,卡在哪一步一眼能分辨。

只连不上而不出结果,用 –connect-timeout 限时,再加 -w 打印总耗时。

curl -v https://api.example.com/health
# 只看耗时分解
curl -o /dev/null -s -w 'dns=%{time_namelookup} conn=%{time_connect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://api.example.com/health
# 限时并跟随重定向
curl -vL --connect-timeout 5 --max-time 15 https://api.example.com/health
THE END
喜欢就支持一下吧
点赞7 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容