curl cheat sheet

Make HTTP requests

GET a website

curl https://example.com

Show response headers

curl -i https://example.com

Follow redirects

curl -L https://example.com

Make a HEAD request

curl -I https://example.com

Output to a file

curl -o out.html https://example.com/

Set a header

curl https://pages.github.io -H "Host: raytracing.github.io"

Override DNS resolution

curl example.com --resolve example.com:443:23.220.75.245

POST some JSON

curl -v httpbin.io/post --data '{"key":"value"}' -H "Content-Type: application/json"

Do basic authentication

curl -u user:pass example.com