Curl is an awesome tool. I keep forgetting the switches though, so here's a cheatsheet.

Simple GET request

curl -k "https://localhost/foo?bar=baz&abc=def"

JSON POST or PUT request

curl -k -H "Content-Type: application/json" -X POST -d '{"accountName":"test","value":"hello"}' https://localhost/foo
curl -X "PUT"

... for a PUT

POST a file

curl ... --data-binary @filename

Fake a /etc/hosts entry and a Host: header with curl

curl -vvv --resolve ''

Make a request with basic auth enabled

curl -vvv -u


curl --user name:password

Set the Referer header

curl -e

Set the User Agent header

curl -A "Mozilla/4.73"


curl --user-agent "Mozilla".

Set Cookies

curl -b "name=Daniel"


curl --cookie "name=Daniel"

Time a request (connect time + time to first byte + total tile)

curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n"

Downloading files from Github

curl -O