curl

21 commands

21 shown

POST JSON payload Send a JSON POST request with Bearer auth curl -s -X POST https://api.example.com/v1/resource -H 'Content-Type: application/json' -H 'Authorization: Bearer <token>' -d '{"key":"value"}' | jq . #curl#network Follow redirects with verbose Show full request/response headers including redirects curl -sLv https://example.com 2>&1 | grep -E '^[<>*]' #curl#network#debug Time a request Measure DNS, connect, and TTFB timing curl -so /dev/null -w 'DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://example.com #curl#network#debug Download with progress Download a file showing a clean progress bar curl -L --progress-bar -o output.file https://example.com/file.tar.gz #curl#network Basic auth request HTTP request with Basic Authentication curl -s -u user:password https://api.example.com/endpoint | jq . #curl#network Check only HTTP status code Get just the response status code — useful in scripts curl -so /dev/null -w '%{http_code}' https://example.com #curl#network#debug POST JSON body Send JSON payload via POST curl -X POST https://api.example.com/v1/items -H 'Content-Type: application/json' -d '{"name":"foo"}' #curl Bearer token auth Attach JWT/Bearer token in Authorization header curl -H 'Authorization: Bearer $TOKEN' https://api.example.com/me #curl#security Follow redirects with verbose Follow up to 5 redirects and show full request/response curl -Lv --max-redirs 5 https://example.com #curl#debug Save response to file Download silently, fail on error, follow redirects curl -sSL -o /tmp/result.json https://api.example.com/data #curl Measure time to first byte Benchmark TTFB and total request time curl -o /dev/null -sS -w 'ttfb: %{time_starttransfer}s\ntotal: %{time_total}s\n' https://example.com #curl#monitoring Show response headers only Print HTTP response headers without body curl -sI https://example.com #curl#debug Upload file multipart Multipart form-data upload with extra fields curl -F 'file=@./report.pdf' -F 'user=alice' https://upload.example.com/api #curl HTTP/2 request Force HTTP/2 and check protocol in response curl --http2 -sI https://example.com | grep -i 'http\|alt-svc' #curl#network Set custom DNS resolver Override DNS for a host:port pair (test behind CDN/LB) curl --resolve example.com:443:1.2.3.4 https://example.com #curl#network#debug Retry on failure Retry up to 5 times with 2s delay on any error curl --retry 5 --retry-delay 2 --retry-all-errors https://api.example.com/healthz #curl POST form data Send URL-encoded form data curl -d 'user=alice&pass=secret' -X POST https://auth.example.com/login #curl Client certificate auth mTLS request with client cert and custom CA curl --cert client.crt --key client.key --cacert ca.crt https://secure.example.com #curl#security Parallel downloads with xargs Download 5 URLs in parallel and print status codes cat urls.txt | xargs -P 5 -I{} curl -sSL -o /dev/null -w '%{url_effective} %{http_code}\n' {} #curl WebSocket handshake test Verify WebSocket upgrade handshake responds with 101 curl -i -N -H 'Upgrade: websocket' -H 'Connection: Upgrade' -H 'Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==' -H 'Sec-WebSocket-Version: 13' http://localhost:8080/ws #curl#network#debug Rate-limit download speed Limit download bandwidth to 1 MB/s curl --limit-rate 1M -O https://example.com/bigfile.iso #curl
no commands match