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}\n'  -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

复制代码
\n 
       time_namelookup: %{time_namelookup}\n time_connect: %{time_connect}\n time_appconnect: %{time_appconnect}\n time_pretransfer: %{time_pretransfer}\n time_redirect: %{time_redirect}\n time_starttransfer: %{time_starttransfer}\n ----------\n time_total: %{time_total}\n \n
复制代码
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}\n' 'http://www.baidu.com'

忽略ssl认证  并输出结果

curl -k -XPOST -w '\n%{time_connect}:%{time_starttransfer}:%{time_total}\n' 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

posted @ 2021-02-25 15:34  马里亚纳仰望星空  Views(139)  Comments(0Edit  收藏  举报