curl 指令速查表
用於 API 偵錯與自動化的 HTTP 用戶端指令:請求方法、JSON 酬載、標頭、驗證、multipart 上傳、Cookie、重試與 curl 8.x 的 TLS 診斷。
運作原理
curl transfers URL data from the shell: set method (-X), headers (-H), body (-d/-F), and output (-v/-i/-w) explicitly, because curl prints only the response body by default.
生存指南
最先需要掌握的少數核心指令。
42 個指令
Requests & Methods
Send GET, HEAD, POST, PUT, PATCH, and DELETE requests with clean headers.
- 必備
Fetch a URL and print the response body to stdout
curl <url>建構指令
curl <url>輸入的值會依原樣插入。若包含空白或特殊字元,請自行加上引號。
使用時機
Baseline check for reachability, response payload, and pipe integration with jq.
範例
curl https://api.example.com/health執行結果
{"status":"ok","version":"2.4.0"}
Payloads, Forms & Files
Send JSON, URL-encoded forms, multipart uploads, and binary bodies.
Auth, Cookies & TLS
Authenticate requests, manage cookies, resolve hosts, and verify certificates.
Headers, Timing & Debugging
Inspect TLS handshakes, response headers, status codes, and per-phase latency.
Downloads, Retries & Limits
Write files safely, resume interrupted downloads, cap wait time, and retry.