curl 命令常用

参考: 

https://www.cnblogs.com/name-lizonglin/p/12167808.html

-- 测试 请求返回时间  测试Pod 之间解析时间   用key为空字符串查memcache 会超时 

参考https://www.cnblogs.com/evenchen/p/12124992.html 

curl -o /dev/null -s -w '%{time_namelookup}:%{time_connect}:%{time_starttransfer}:%{time_total} '  -H "Content-Type: application/json"  -XPOST -d '{"ext":"{}","params":{"channel":"","userId":""},"sign":""}'    'https://servicename.default.svc.cluster.local:8901/ext/yt//get_work_flow_status1'

### shell 脚本for 循环

#/bin/bash
#file='/home/yyapp/wecha.txt'
file='/home/yyapp/wwww.txt'
for i in `cat $file` :
do
echo $i
data='{"openid_list":["'$i'"],"tagid" : 111}'
echo $data

curl -H 'Content-Type: application/json' -XPOST -d $data 'https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=4PID'
sleep 0.1
done

-- 

1、vim curl

curl 命令常用
 
       time_namelookup: %{time_namelookup} time_connect: %{time_connect} time_appconnect: %{time_appconnect} time_pretransfer: %{time_pretransfer} time_redirect: %{time_redirect} time_starttransfer: %{time_starttransfer} ---------- time_total: %{time_total}
curl 命令常用
time_namelookup:DNS解析域名时间,把域名--->ipd的时间
time_connect:TCP连接的时间,三次握手的时间
time_appconnect:SSL|SSH等上层连接建立的时间
time_pretransfer:从请求开始到到响应开始传输的时间
time_redirect:从开始到最后一个请求事务的时间
time_starttransfer:从请求开始到第一个字节将要传输的时间
time_total:总时间

2、eg

  curl -w "@curl" -o /dev/null -s -d "username=aaa&password=bbb" https://xxx.xxx.com/webapp/xxx/login

 -w:从文件中读取信息打印格式

 -o:输出的全部信息

 -s:不打印进度条

 -d:参数

3、简单的方式

curl -o /dev/null -s -w '%{time_connect}:%{time_starttransfer}:%{time_total} ' 'http://www.baidu.com'

忽略ssl认证  并输出结果

curl -k -XPOST -w ' %{time_connect}:%{time_starttransfer}:%{time_total} ' www.baidu.com

4、当Content-Type:application/json,requestBody:{id: 93, status: 2}

 curl -w "@curl" -H "Content-Type:application/json" -X PUT --data '{id: 93, status: 2}' http:/xxxxxxxxxxx/changeStatus