curl 查看出口IP
curl ip.cn/cip.cc
# 查询ip地址所在地
curl -s cip.cc/8.8.8.8 |grep 地址
地址 : 美国 XX
curl 指定DNS解析
# 将cdn.chegva.com解析到1.180.235.215访问
curl -Lvo /dev/null https://cdn.chegva.com/image/1642000893511364.jpeg \
--resolve "cdn.chegva.com:443:1.180.235.215"
curl 分析静态页面请求时间
curl -w "@curl-format.txt" -o /dev/null -s -L "http://chegva.com"
cat curl-format.txt
time_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
curl -w "http_code: %{http_code}\ntime_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_redirect: %{time_redirect}\ntime_pretransfer: %{time_pretransfer}\ntime_starttransfer: %{time_starttransfer}\n----------\ntime_total: %{time_total}\n" -o /dev/null -s -L "chegva.com"
http_code: 200
time_namelookup: 0.005
time_connect: 0.009
time_appconnect: 0.061
time_redirect: 3.545
time_pretransfer: 0.061
time_starttransfer: 0.500
----------
time_total: 4.105
time_namelookup:DNS 域名解析的时候,就是把 http://chegva.com 转换成 ip 地址的过程
time_connect:TCP 连接建立的时间,就是三次握手的时间
time_appconnect:SSL/SSH 等上层协议建立连接的时间,比如 connect/handshake 的时间
time_redirect:从开始到最后一个请求事务的时间
time_pretransfer:从请求开始到响应开始传输的时间
time_starttransfer:从请求开始到第一个字节将要传输的时间
time_total:这次请求花费的全部时间
curl 防盗链测试
curl -I https://chegva.com/anzhihe.jpg -H "referer:https://www.google.com"
curl cookie
curl --cookie "name=Daniel" http://chegva.com
curl --trace-ascii debugdump.txt http://chegva.com
curl 跨域测试
curl -I -X OPTIONS -H "Origin: https://www.chegva.com" https://chegva.com
curl token
curl -s -H 'X-Auth-Token: f9d6a2e8-1713-491a-aa7f-15d5353' "http://chegva.com/v1/info"
curl 安装脚本
curl -Ss -u sagent:54445cdcf330065xxerr347948bcdc92b5849 http://chegva.com/install.sh | bash
curl salt api验证
curl -ki https://127.0.0.1:8080/login -H "Accept: application/json" \
-d username='salt' \
-d password='salt_pass' \
-d eauth='pam'
curl -i http://localhost:8080/ -H "Accept: application/json" -H "X-Auth-Token: b363bf8b7a34c6a5db6719d745e32df38329a43e" -d client='local' -d tgt='minion-id1' -d fun="cmd.run" -d arg="uname -a"
curl get 返回json类型
curl -X GET --header 'Accept: application/json' 'http://chegva.com/search/hehe?search=xx.xx.xx' 2>/dev/null |grep -v '<a' | python -m json.tool
[
{
"cluster": "xxoo",
"create_time": "2018-05-02 18:55:39",
"creator": "anzhihe",
"id": 111
}
]
curl post json类型数据
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d ' { \
"cluster": "chegva.com", \
"create_time": "2018-05-02 18:55:39", \
"creator": "anzhihe", \
"id": 110 \
}' 'http://chegva.com/v1/add/cluster'
curl delete
curl -X DELETE --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"ids": "xxoo" \
}' 'http://chegva.com/v1/cluster/del'
curl put
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{ \
"rips": "100", \
"vs_id": 110 \
}' 'http://chegva.com/v1//edit/weight'
curl 查看网页是否开启gzip
curl -I -H "Accept-Encoding: gzip,deflate" https://chegva.com (看最后一行是否有Content-Encoding: gzip)
参考: