zjunebao
12/7/2019 - 11:19 AM

CURL command

Testing connect

# retrieve content
curl domain.com

# retrieve headers only
curl -I domain.com
# check http/2 support
curl -I --http2 domain.com

# display more info (-v to any command)
curl domain.com -v

Go to the redirection

curl -L domain.com

Download

# test speed
curl -D - https://domain.com -o /dev/null

# download
curl -O https://domain.com/main.min.css

# output to a file
curl http://domain.com > web.html

# save in different file name
curl -o main.css https://domain.com/main.min.css

# resume interrupted download
curl -C - -O https://domain.com/large.zip

# when redirect, use -L
curl -LO https://domain.com/large.zip

# set maximum transfer rate
curl --limit-rate 200k -O https://domain.com/large.zip

Methods

curl --request GET https://domain.com
curl --request POST https://domain.com
curl --request DELETE https://domain.com
curl --request PUT https://domain.com

# POST with data
curl -X POST https://domain.com -d 'username=a&password=b'

Cookies

# receive cookies
curl https://domain.com -c cookies.txt

# send cookies
curl https://domain.com -b cookies.txt

# send and receive together
curl https://domain.com -c cookies.txt -b cookies.txt