Installation
homebrew
http://conqueringthecommandline.com/book/curl
1. install/update curl on mac using brew on terminal
brew install curl2. simple test
curl https://www.google.com
Commands
Click here to expand...
http://conqueringthecommandline.com/book/curl
1. simple test
curl https://www.google.com2. with info (-i)
curl -i https://www.google.com3. following redirects (-L)
curl quiet-waters-1228.herokuapp.com/redirectme curl -L quiet-waters-1228.herokuapp.com/redirectme4. downloading files (-O)
curl http://quiet-waters-1228.herokuapp.com/assets/image.jpg curl -O http://quiet-waters-1228.herokuapp.com/assets/image.jpgwill save be saved into file named image.jpg
5. Custom file names (-o)
curl -0 custom_name.jpg http://quiet-waters-1228.herokuapp.com/assets/image.jpg6. changing HTTP request method (-X)
curl -i -X POST https://httpbin.org/post curl -i -X GET https://httpbin.org/getand so on …
sending parameters curl -i -X GET https://httpbin.org/get?hello=world7. passing data in a request body (-d)
curl -i -X POST https://httpbin.org/post -d "hello=world&jesus=christ"using file for request body (file name prefixed with @)
curl -X POST https://httpbin.org/post -d @form_data.json8. setting headers (-H)
curl -X POST https://httpbin.org/post -d @form_data.json -H "Accept: application/json"9. basic http authentication (-u)
curl -i -X POST quiet-waters-1228.herokuapp.com/login curl -X POST -u "user1:password1" quiet-waters-1228.herokuapp.com/login10. saving and sending cookies/headers (-D, -b)
11. cookie jar (-c)
curl -X POST -c cookies.txt -u "user1:password1" quiet-waters-1228.herokuapp.com/login saves cookies into cookies.txt