Skip to content

Instantly share code, notes, and snippets.

@petergi
Last active January 8, 2024 03:32
Show Gist options
  • Select an option

  • Save petergi/2ab5e502c18dbb0eb66b2b368e7bc81f to your computer and use it in GitHub Desktop.

Select an option

Save petergi/2ab5e502c18dbb0eb66b2b368e7bc81f to your computer and use it in GitHub Desktop.

Curl cheatsheet

Options

-o <file>    # --output: write to file
-u user:pass # --user: Authentication
-v           # --verbose
-vv          # Even more verbose
-s           # --silent
-I           # --head: headers only

Request

-X POST          # --request
-L               # follow link if page redirects 

Data

-d 'data'    # --data: HTTP post data, URL encoded (eg, status="Hello")
-d @file     # --data via file
-G           # --get: send -d data via get

Headers

-A <str>         # --user-agent
-b name=val      # --cookie
-b FILE          # --cookie
-H "X-Foo: y"    # --header
--compressed     # use deflate/gzip

SSL

    --cacert <file>
    --capath <dir>
-E, --cert <cert>     # --cert: Client cert file
    --cert-type       # der/pem/eng
-k, --insecure        # for self-signed certs

Examples

# Post data:
curl -d password=x http://x.com/y
# Auth/data:
curl -u user:pass -d status="Hello" http://twitter.com/statuses/update.xml
# multipart file upload
curl -v -include --form key1=value1 --form upload=@localfilename URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment