cURL — The Swiss Knife of HTTP Requests
● Basic Requests
1. GET request
curl https://example.com
2. Save response to a file
curl -o output.html https://example.com
3. Follow redirects
curl -L https://example.com
━━━━━━━━━━━━━━━━━━
● HTTP Methods
1. POST request
curl -X POST https://httpbin.org/post
2. Send JSON data
curl -X POST https://httpbin.org/post -H "Content-Type: application/json" -d '{"username":"test","password":"1234"}'
3. PUT request
curl -X PUT https://httpbin.org/put
4. DELETE request
curl -X DELETE https://httpbin.org/delete
━━━━━━━━━━━━━━━━━━
● Headers & Authentication
1. Add custom header
curl -H "X-Test-Header: hello" https://httpbin.org/headers
2. View response headers
curl -I https://example.com
3. Include headers in output
curl -i https://example.com
━━━━━━━━━━━━━━━━━━
● Cookies
1. Send cookies
curl -b "session=abc123" https://httpbin.org/cookies
2. Save cookies
curl -c cookies.txt https://httpbin.org/cookies/set/session/abc123
3. Load cookies
curl -b cookies.txt https://httpbin.org/cookies
━━━━━━━━━━━━━━━━━━
● Proxy Usage
1. HTTP Proxy
curl -x http://127.0.0.1:8080 https://example.com
2. SOCKS5 Proxy
curl --socks5 127.0.0.1:9050 https://example.com
✧ Tip: Use test data like test and abc123, and never post real passwords or tokens.
~~~~
Proxy commands require an active proxy.