Essential Curl Commands for Testing and Development
A comprehensive guide to essential curl commands for HTTP testing, API development, and web debugging.
Submit form data using the standard application/x-www-form-urlencoded format:
curl --data "key1=value1&key2=value2" http://site.com
Send JSON payloads to REST APIs with proper content-type headers:
curl -H 'Content-Type: application/json' \
--data '{"param1":"test1","param2":"test2"}' \
http://test.com
Retrieve only the HTTP status code without the response body:
curl -s -o /dev/null -w "%{http_code}" http://www.example.org/
Follow redirects:
curl -L http://example.com
Save response to file:
curl -o output.html http://example.com
Include response headers:
curl -i http://example.com
Set custom headers:
curl -H "User-Agent: My-App/1.0" http://example.com
POST with file upload:
curl -F "[email protected]" http://example.com/upload