我可以只卷曲响应代码吗? [英] Can I have curl print just the response code?

查看:50
本文介绍了我可以只卷曲响应代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了 https://superuser.com/questions/272265/getting -curl-to-output-http-status-code 。它提到

curl -i 

将打印HTTP响应代码。是否可以在HTTP响应代码中仅 卷曲打印?是否有通用的方法来获取任何类型的请求(例如GET / POST / etc)的HTTP状态代码?

will print the HTTP response code. Is it possible to have curl print just the HTTP response code? Is there a generic way to get the HTTP status code for any type of request like GET/POST/etc?

我在Mac OS High Sierra上使用curl 7.54.0 。

I am using curl 7.54.0 on Mac OS High Sierra.

感谢阅读。

推荐答案

这对我有用:

$  curl -s -w "%{http_code}\n" http://google.com/ -o /dev/null

这篇关于我可以只卷曲响应代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆