curl: HTTP from the Command Line
Drive HTTP from your terminal with curl — read responses and headers, follow redirects, send forms and JSON, authenticate, upload files, handle cookies, and pipe the result straight into your tools.
curl is the universal HTTP client: it's on every server you SSH into, it speaks every method, and it shows you exactly what went over the wire. We start from a plain GET and build up real fluency one flag at a time — inspecting headers, following redirects, saving files, posting forms and JSON, setting custom headers, authenticating, uploading, juggling cookies, and shaping requests with query strings. By the end you can read a response down to its status code, fail loudly in a script, and pipe JSON straight into jq. Every step is one command and its exact output, so each flag lands on its own.
What you'll build
- Make requests and read responses, headers, and status codes
- Follow redirects and save responses to files
- Send form data and JSON, and switch HTTP methods
- Set custom headers and authenticate with basic auth and tokens
- Upload files and manage cookies across requests
- Fail loudly in scripts and pipe results into other tools
Contents
- Check your curl
- Your first request
- A server that talks back
- Show the response headers
- Headers only
- See the whole conversation
- Quiet the progress meter
- Follow redirects
- Save to a file you name
- Save under its remote name
- Post form data
- Encode values safely
- Send JSON the short way
- Set the content type by hand
- Choose the method
- Delete a resource
- Send a custom header
- Basic authentication
- Send a bearer token
- Upload a file
- Save the cookies you receive
- Send the cookies back
- Add a query string
- Build a query string safely
- Print just the status code
- Fail on error responses
- Fail, but keep the body
- Pin a hostname to an IP
- Retry transient failures
- Set the user agent
- Skip certificate checks — carefully
- Pipe JSON into jq
- Put it together
- Make it your own