Skip to content

Instantly share code, notes, and snippets.

@albohlabs
Created March 6, 2012 22:09
Show Gist options
  • Save albohlabs/1989318 to your computer and use it in GitHub Desktop.
Save albohlabs/1989318 to your computer and use it in GitHub Desktop.
CLI: curl
## save file
curl -O [URL]
## show headers
curl -v [URL]
## Custom Request
curl --data "<xml>" --header "Content-Type: text/xml" --request PROPFIND [URL]
# ruin the request by chopping off the Host: header:
curl --header "Host:" [URL]
curl --header "Destination: http://nowhere" [URL]
## POST
# Content-Type: application/x-www-form-urlencoded
curl --data "birthyear=1905&press=%20OK%20" [URL]
# space -> %20
curl --data-urlencode "name=I am Daniel" http://www.example.com
## file upload POST
curl --form upload=@localfilename --form press=OK [URL]
## PUT
curl --upload-file uploadfile [URL]
## HTTP Authentication
curl --user name:password [URL]
## Referer
curl --referer [URL] [URL]
## User Agent
curl --user-agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" [URL]
curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" [URL]
## follow Redirects
curl --location [URL]
## Cookies
curl --cookie "name=Daniel" [URL]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment