Simple understanding and use of some curl commands

Note: The domain name and URL in the following example are changed according to the actual situation during the test

Curl loop test (take 66 cycles as an example, use null.jpg instead of url. When testing, you can change it to the url you want to test, the port 80 and port 43 of the domain name tested here, you can also test other ports)

ipv6
for ((i=0;i<66;i++));do hc=`curl -o /dev/null -s -w %{http_code} http:/ / write the domain name here / null.jpg -x [ Write ipv6 address here] :80`;echo $i,$hc;done

for ((i=0;i<200;i++));do hc=`curl -6 -k -g -o /dev/null -s -w %{http_code} "https:// [write ipv6 here address] : 443 / this is written at the domain /null.jpg"`;echo $ i, $ hc; done

ipv4
for ((i=0;i<66;i++));do hc=`curl -o /dev/null -s -w %{http_code} http:// write domain name here /lnull.jpg -x this Write IP address : 80`;echo $i,$hc;done
for ((i=0;i<66;i++));do hc=`curl  -k -o /dev/null -s -w %{http_code} "https://1此处写IP地址:443/wx3.sinaimg.cn/null.jpg"`;echo $i,$hc;done

curl test to get download time

curl -vo /dev/null "http://www.abc.com" -x 1.1.1.1:80

curl -vo /dev/null "http://www.abc.com/null.jpg" -x 1.1.1.1:80

curl to view the response time of the machine

curl -vo /dev/null "http://www.abv.com" -x 127.0.0.1:80

curl test whether the domain name supports http2.0 (tested on centos8 devices)

curl --http2   -I  /dev/null "https://www.abc.com/null.jpg" --resolve www.abc.com:443:1.1.1.1

Test whether to ignore the cache

curl -svo /dev/null  http://$name/null.jpg -x www.abc.com:80
curl -svo /dev/null  http://$name/null.jpg?a=1 -x www.abc.com:80

Compare the two commands to observe whether the x-cache value has changed

The x-cache value remains unchanged: the domain name allows the cache to be ignored

x-cache value changed: domain name is not allowed to ignore cache

Cross-domain testing

curl -svo  /dev/null http://$name/null.jpg -H "Origin:www.baidu.com" -x  www.abc.com :80

refer anti-hotlink test

curl -svo 1 'http://www.abc.com/null.jpg  ' -x 1.1.1.1:80 -H "referer:http://www..baidu.com/u/2287091337"

 





Guess you like

Origin blog.51cto.com/13403516/2668441