Curl
- Similar to
wget
- Mostly used for REST request
--request (-X)
curl https://httpbin.org/get -X GET
--data (-d)
# json
curl https://httpbin.org/post \
-X POST \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
# url-encoded
curl https://wordpress.com/wp.login.php \
--data "log=admin&pwd=password"
# from file
curl https://httpbin.org/post \
--request POST \
--header "Content-Type: application/json" \
--data @search.json
- Add headers to the request
curl https://httpbin.org/post \
-X POST \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
--silent (-s)
curl -s https://httpbin.org/get
--remote-name (-O)
- Save file with its original filename
curl http://mirror.bytemark.co.uk/ubuntu-releases/18.04.4/ubuntu-18.04.4-desktop-amd64.iso -O
--output (-o)
- Save file with a provided filename
curl example.com -o example.html
--head (-I)
- Show response headers only
--list-only (-l)
- Saves the redirected page
- The http page is redirecting to the https page, so nothing is displayed
--location (-L)
curl -L https://deb.nodesource.com/setup_14.x | bash -
--verbose (-v)
- TLS handshake - Additional information regarding the connection