GET请求

  • GET请求只需要在curl命令后加待请求的URL即可。
    curl url
    eg: curl ‘http://github.com

POST请求

  • POST请求格式稍显复杂
    curl -H “Content-Type: application/json” -X POST –data ‘json 报文’ url
    eg: curl -H “Content-Type: application/json” -X POST –data ‘{“app: “curl”}’ http://google.com

过程时间

  • 计算整个过程时间:
    -w %{time_total}

  • 其它时间:  -w:按照后面的格式写出rt time_namelookup:DNS 解析域名[www.tn.com]的时间  time_commect:client和server端建立TCP 连接的时间 time_starttransfer:从client发出请求;到web的server 响应第一个字节的时间 time_total:client发出请求;到web的server发送回所有的响应数据的时间 speed_download:下周速度  单位 byte/s

  • eg: curl -o /dev/null -s -w time_namelookup:"\t”%{time_namelookup}"\n"time_connect:"\t\t"%{time_connect}"\n"time_appconnect:"\t"%{time_appconnect}"\n"time_pretransfer:"\t"%{time_pretransfer}"\n"time_starttransfer:"\t"%{time_starttransfer}"\n"time_total:"\t\t"%{time_total}"\n"time_redirect:"\t\t"%{time_redirect}"\n" -H “Content-Type: application/json” -X POST –data ‘json data’ url