废话不多说,直接上代码示例:
# GET请求
curl -XGET --write-out '%{http_code} %{time_total}' --silent --output /dev/null --connect-timeout 3 https://www.baidu.com
# POST请求
curl -XPOST -u dev:123456 --write-out '%{http_code} %{time_total}' --silent --output /dev/null --connect-timeout 3 http://192.168.100.200/api/user/login
此处执行会返回请求码 请求耗时单位秒
想要获取更多curl命令的返回结果,使用man curl查看手册内容即可。