选项
-w
从文件中读取要打印信息的格式-o
/dev/null:把响应的内容丢弃,因为我们这里并不关心它,只关心请求的耗时情况-s
不要打印进度条-L
页面使用了301重定向,这时我们可以添加-L参数来跟踪URL重定向-i
--include
查看头信息, 页面响应头会和页面源码(响应体)一起返回-I
--head
只返回头信息不返回页面源码-X
指定请求方法,配合--data
添加提交数据--data
添加提交数据,格式:”a=a1&b=b1”-H
--header
来指定请求头:curl -H 'Content-Type:application/json' -H 'Authorization: bearer eyJhbGciOiJIUzI1NiJ9' itbilu.com
请求耗时查看
使用curl -w命令
配置文件
新建curl-format.txt
文件,内容为:1
2
3
4
5
6
7
8time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_redirect: %{time_redirect}\n
time_pretransfer: %{time_pretransfer}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
使用1
2
3
4
5
6
7
8
9curl -w "@curl-format.txt" -o /dev/null -s -L "http://cizixs.com"
time_namelookup: 0.012
time_connect: 0.227
time_appconnect: 0.000
time_redirect: 0.000
time_pretransfer: 0.227
time_starttransfer: 0.443
----------
time_total: 0.867
使用httpstat命令
安装pip install httpstat
使用1
2
3
4
5# 默认请求
httpstat www.baidu.com
# form表单提交
httpstat www.baidu.com -XPOST --data "a=a1&b=b1"