Skip to content

Instantly share code, notes, and snippets.

@jeromecovington
Last active November 10, 2021 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeromecovington/037db48db7cff210f62d2c38e2054351 to your computer and use it in GitHub Desktop.
Save jeromecovington/037db48db7cff210f62d2c38e2054351 to your computer and use it in GitHub Desktop.
Curl in brief

Basic

curl https://www.keycdn.com

Returning only the HTTP headers of a URL

curl -I https://www.keycdn.com

Saving the result of a curl command

...with a specific filename.

curl -o myfile.css https://cdn.keycdn.com/css/animate.min.css

...with the same filename.

curl -O https://cdn.keycdn.com/css/animate.min.css

Adding an additional HTTP request header

curl -H "X-Header: value" https://www.keycdn.com

Generating additional information (verbose)

curl -H "X-Header: value" https://www.keycdn.com -v

Resuming a download

curl -C - -O https://cdn.keycdn.com/img/cdn-stats.png

Storing HTTP headers

curl -D - https://www.keycdn.com/

Testing the download time of an asset without any output

curl -D - https://www.keycdn.com/ -o /dev/null

Specifying a maximum transfer rate

curl --limit-rate 200K -O https://cdn.keycdn.com/img/cdn-stats.png

HTTP/2 support check

curl -I --http2 https://cdn.keycdn.com/

Retrieving a particular byte-range

curl -r 0-20000 -o myfile.png https://cdn.keycdn.com/img/cdn-stats.png

Simulate HTTP methods

curl --request GET https://www.keycdn.com/
curl --request POST https://yourwebsite.com/
curl --request DELETE https://yourwebsite.com/
curl --request PUT https://yourwebsite.com/
curl -X POST http://www.yourwebsite.com/login/ -d 'username=yourusername&password=yourpassword'
curl --H "Content-Type: application/json" \
  --request POST \
  --d '{"username":"xyz","password":"xyz"}' \
  http://www.yourwebsite.com/login/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment