cURL (Client URL) is the ubiquitous command-line tool for transferring data over network protocols including HTTP, HTTPS, FTP, and WebSockets. Essential for backend developers, API engineers, and system administrators, cURL enables testing REST/GraphQL endpoints, inspecting HTTP response headers, sending custom payloads, and debugging network handshakes.
Key Takeaways
- Use `curl -I` or `curl -i` to inspect HTTP response status codes and server headers.
- Send JSON API payloads using `curl -X POST -H "Content-Type: application/json" -d '{...}'`.
- Include Bearer tokens or Basic auth credentials using `-H "Authorization: Bearer <token>"`.
- Leverage `curl --http3-only` to test modern HTTP/3 QUIC network protocol connections.
How do you make basic GET requests and save HTTP output in cURL?
GET requests fetch server resources and can either print response bodies to stdout or save them directly to local files.
# Fetch web page content and output to stdout
curl https://meshworld.in
# Save remote content to a local file (preserves remote filename)
curl -O https://example.com/downloads/installer.tar.gz
# Save remote content to a custom local filename
curl -o custom-name.tar.gz https://example.com/downloads/installer.tar.gz
# Silently fetch content without progress meters
curl -s https://api.github.com/zen
# Follow HTTP 301/302 redirects automatically
curl -L https://meshworld.inHow do you send POST, PUT, DELETE, and JSON payloads with cURL?
HTTP method requests are specified using -X (--request), while request data payloads are passed via -d (--data).
| Command Syntax | Usage |
|---|---|
curl -X POST <url> | Send empty HTTP POST request |
curl -X POST -d "param1=value1¶m2=value2" <url> | Send form-urlencoded POST payload |
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' <url> | Send raw JSON payload to REST API |
curl -X PUT -d @data.json <url> | Send HTTP PUT request using file content |
curl -X DELETE <url> | Send HTTP DELETE request to endpoint |
How do you pass custom headers, cookies, and authentication?
Custom HTTP headers are attached using -H, while authentication credentials use -u or Bearer header tokens.
# Send custom User-Agent header
curl -H "User-Agent: CustomApp/1.0" https://api.example.com
# Send Bearer authentication token header
curl -H "Authorization: Bearer secret_api_token_123" https://api.example.com/user
# HTTP Basic Authentication (username:password)
curl -u admin:secret123 https://api.example.com/admin
# Send session cookies directly
curl --cookie "sessionid=abc123xyz" https://example.com/dashboard
# Save response cookies to file (cookie jar)
curl -c cookies.txt https://example.com/loginHow do you debug SSL certificates, timing metrics, and test HTTP/3?
Advanced cURL flags provide low-level insights into TLS handshakes, response timing breakdowns, and QUIC protocol support.
# Print verbose output showing request/response headers and TLS handshake
curl -v https://meshworld.in
# Ignore self-signed or invalid SSL certificate errors (Insecure mode)
curl -k https://localhost:8443
# Force cURL to use HTTP/3 QUIC connection
curl --http3-only https://cloudflare.com
# Display exact timing metrics (DNS lookup, TCP connect, TTFB, total time)
curl -w "DNS: %{time_namelookup}s | Connect: %{time_connect}s | TTFB: %{time_starttransfer}s | Total: %{time_total}s\n" -o /dev/null -s https://meshworld.inFrequently Asked Questions
What is the difference between -i, -I, and -v in cURL?
-i includes HTTP response headers along with the body text. -I fetches HTTP headers ONLY (performs a HEAD request). -v enables verbose mode, printing request headers, TLS handshake details, and response headers.
How do I upload files via cURL using multipart form data?
Use the -F (--form) flag with @ before the local file path (e.g. curl -F "file=@/path/to/image.png" https://example.com/upload).
What to Read Next
- jq Cheat Sheet: JSON Filtering & Transformation — Parse cURL JSON output directly in terminal.
- Linux Bash Cheat Sheet: Commands & Scripting — Shell automation scripts.
- Vim Cheat Sheet: Modes & Navigation — Terminal editing tools.



