curl command cheat sheet

 In this tutorial. I writen curl command cheat sheet. 

curl cheat sheet


Option

-o <file>       # --output: write to file
-u user:pass  # --user: Authentication
-v                  # --verbose
-s                  # --silent
-I                  # --head: headers only
-i                  # --include: Include the HTTP-header in the output
Request

-X POST          # --request
-L                     # follow link if page redirects
-F                     # --form: HTTP POST data for multipart/form-data


Headers

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


Data

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


SSL

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

Curl command examples


curl Get/Head

#Curl head request
curl -I https://www.google.com
#Curl head request with verbose
curl -v -I https://www.google.com
#Curl get response with headers
curl -k -v https://www.google.com


CURL POST

#Curl post request
curl -d "name=username&password=1111111111" <URL>
#Curl post send json
curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}"



CURL ADVANCED

 

#Get my public ip
curl -L -s http://whatismijnip.nl
curl -L -s http://ipecho.net/plain
#Curl upload
curl -v -F key1=value1 -F [email protected] <URL>
#Curl with http2
curl -k -v --http2 https://www.google.com/
#Curl ftp upload
curl -T file.zip -u test:test ftp://10.10.1.23/
#Curl ftp download
curl -u test:test ftp://10.10.1.23/file.zip -o file.zip


No comments:

Post a Comment