curl#
Main Arguments#
-o, --output <file>: Write output to a specific file.- Useful when the response is binary or too verbose to display in the terminal.
- cf.
wget:-O, --output-documentis for the response body, while-o, --output-fileredirects log messages.
-w, --write-out <format>: Display information on stdout after a completed transfer.- Useful for extracting specific metadata like HTTP status codes. Refer to
man curland search for/-wor/--write-outfor the full list of variables. - eg.
curl example.com -o /dev/null -w '%{http_code}\n', Checks the HTTP status code without printing the response body.
- Useful for extracting specific metadata like HTTP status codes. Refer to
AuthN#
The HTTP header is named
Authorization, but it is technically used for AuthN—identifying who you are—rather than AuthZ.
L4 TLS/SSL#
Used to authenticate the server and optionally the client and establish an encrypted channel.
- Server-side AuthN:
-k, --insecure: Allow “insecure” server connections when using SSL. It skips the verification of the server’s certificate.- cf.
wget:--no-check-certificate
- cf.
--cacert <file>: Specify a custom CA certificate file to verify the peer.
- Client-side AuthN mTLS:
--cert <certificate>: Specify the client certificate file (x.509).--key <key>: Specify the private key file.
L7 Headers#
Used to provide credentials to the application.
- Bearer Token:
curl -H "Authorization: Bearer <token>" <url> - Basic Auth:
- Header:
curl -H "Authorization: Basic $(echo -n 'ID:PW' | base64)" <url> - Native:
curl -u ID:PW <url>, Automatically encodes to base64
- Header: