$ command-helper

curl

HTTP requests from the terminal: headers, JSON, auth, uploads, timings and debugging.

Requires Google sign-in

Basic requests

GET request
curl <url>
Follow redirects
curl -L <url>
Show response headers only
curl -I <url>
Show headers and body
curl -i <url>
Download a file keeping its name
curl -LO <url>
Download to a specific file
curl -L -o <file> <url>

Sending data

POST JSON
curl -X POST <url> \
  -H 'Content-Type: application/json' \
  -d '{"name": "test"}'
POST JSON from a file
curl -X POST <url> -H 'Content-Type: application/json' -d @body.json
Submit a form
curl -X POST <url> -d 'user=alice&role=admin'
Upload a file (multipart)
curl -X POST <url> -F 'file=@./photo.jpg'
DELETE request
curl -X DELETE <url>

Auth and headers

Bearer token
curl -H 'Authorization: Bearer <token>' <url>
Basic auth
curl -u <user>:<password> <url>
Custom header and user agent
curl -H 'X-Request-Id: 123' -A 'my-client/1.0' <url>
Send and save cookiesadvanced
curl -b cookies.txt -c cookies.txt <url>

Debugging

Verbose output (TLS, headers)
curl -v <url>
Only the status code
curl -s -o /dev/null -w '%{http_code}\n' <url>
Request timing breakdownadvanced
curl -s -o /dev/null -w 'dns %{time_namelookup}s | connect %{time_connect}s | tls %{time_appconnect}s | first byte %{time_starttransfer}s | total %{time_total}s\n' <url>
Ignore an invalid certificate
curl -k <url>

For local testing only.

Send a request to a specific IP (bypass DNS)advanced
curl --resolve <domain>:443:<ip> https://<domain>/
Pretty-print a JSON response
curl -s <url> | jq
Retry on failure with a timeoutadvanced
curl --retry 3 --retry-delay 2 --max-time 10 <url>