Network
HTTP & curl — make, read, and debug requests
Build any HTTP request from the terminal, read what came back, and trace a failing call from status line to TLS to timing.
Docs-checkedhttpcurltlsheadersdebugging
Quick reference — reach for these first
GET
curl shipreadymetrics.comBasic request. curl adds https:// if you omit the scheme on a bare host.inspect
curl -sSI scm.ccHeaders only (-I), silent but keep errors (-sS). Read the status line first.timing
curl -sS -o /dev/null -w '%{http_code} %{time_total}s' scm.ccStatus + total time, no body. Which phase is slow comes next.POST json
curl -X POST -H "Content-Type: application/json" -d '{"k":"v"}' scm.ccSet the type AND send the body. A 415 means the header is missing.auth
curl -H "Authorization: Bearer TOKEN" scm.ccBearer token. 401 = bad/missing token; 403 = valid token, no access.What the status code tells you
Text equivalent: A curl request goes from client to server and a response comes back. The status code's first digit tells you who owns the problem: 2xx succeeded, 3xx redirects elsewhere, 4xx is your request (401/403 auth, 404 wrong path), 5xx is the server (502/504 a bad or slow upstream).
Common tasks
Task · Command · What to check
| Task | Command | What to check |
|---|---|---|
| Follow redirects | curl -L scm.cc | Final URL and status; -I -L shows each hop. |
| See the full exchange | curl -v scm.cc | > request lines, < response lines, * TLS/connection notes. |
| Headers only | curl -sSI scm.cc | Status line, Content-Type, Set-Cookie, cache headers. |
| Send a form body | curl -d "email=a@b.co&plan=pro" scm.cc | Implies application/x-www-form-urlencoded. |
| Send JSON from a file | curl -H 'Content-Type: application/json' --data-binary @body.json scm.cc | --data-binary keeps newlines; -d strips them. |
| Basic auth | curl -u USER:PASS scm.cc | 401 cleared? Prefer -u over putting creds in the URL. |
| Custom method | curl -X DELETE -H 'Authorization: Bearer TOKEN' scm.cc/items/42 | Response status; 405 means the method isn't allowed. |
| Time each phase | curl -w '@curl-format.txt' -o /dev/null -sS scm.cc | DNS vs connect vs appconnect(TLS) vs starttransfer(TTFB). |
| Force HTTP/1.1 or /2 | curl --http1.1 scm.cc | Rule out an HTTP/2 negotiation issue. |
| Inspect the TLS cert | curl -vI https://app.shipreadymetrics.com 2>&1 | grep -iE 'subject|expire|issuer' | SNI matches, not expired, chain complete. |
| Save the response | curl -O https://app.shipreadymetrics.com/report.csv | -O keeps the remote name; -o NAME renames. |
| Resume a download | curl -C - -O https://app.shipreadymetrics.com/big.tar | Picks up where an interrupted transfer stopped. |
Worked example — a POST returns 401
TRACE IT
1
Reproduce and read the status line only.
curl -sS -o /dev/null -w '%{http_code}\n' \
-X POST -H "Authorization: Bearer $TOKEN" scm.cc/api/jobs
# 4012
Is the header actually being sent? Watch the request.
curl -v -X POST -H "Authorization: Bearer $TOKEN" scm.cc/api/jobs 2>&1 | grep -i '^> auth'
# (empty) → $TOKEN was unset, so no header went out3
Confirm the token is actually set.
echo "${#TOKEN} chars" # 0 means the var is empty
# 0 chars✓
Export a real token, retry, and verify a 2xx. 401 → 201 confirms it was a missing header, not a bad credential.
Troubleshooting — symptom → first check → next check
| Symptom | First check | Establishes | Next check |
|---|---|---|---|
| 401 Unauthorized | curl -v … | grep '^> auth' | Header sent vs token rejected | Check token value / scope |
| 403 Forbidden | Re-read the response body | Authenticated but not allowed | Check role / resource ownership |
| 404 Not Found | curl -IL scm.cc/path | Wrong path vs missing redirect | Confirm base URL + trailing slash |
| 415 Unsupported Media | Echo your -H flags | Content-Type missing/wrong | Add -H 'Content-Type: application/json' |
| SSL certificate problem | curl -vI https://HOST | Expiry / chain / SNI | Test with --resolve or -servername |
| 502 / 504 | curl -w '%{time_total}' | Upstream down vs slow | Check backend health + timeouts |
References
- curl manual (man page)curl.se
- curl --write-out variablescurl.se
- MDN — HTTP response status codesdeveloper.mozilla.org
- MDN — HTTP headersdeveloper.mozilla.org
Assumes curl ≥ 7.75 on Linux/macOS. app.shipreadymetrics.com and scm.cc are used as example hosts; replace with your own. Placeholders in CAPS.