GET request
curl http://example.com/posts/3
Show only head of the response
curl --head http://www.example.com/posts/3
Save the Output to output.txt file
curl -o output.txt http://www.example.com/posts/3
Download the Remote File
curl -O http://www.example.com/posts/3
Sending Post Requests:
curl --data "username=admin&password=admin" http://www.example.com/login
curl --d "username=admin&password=admin" http://www.example.com/login
Put requests:
curl -X PUT -d curl --data "title=change me" http://example.com/posts/3
Delete Request:
curl -X DELETE http://www.example.com/posts/3
Adding Authantication:
curl -u username:password http://www.example.com/posts/3
Curl and FTP
Uploading: curl -u account@website.com:password -T local_file.txt ftp://ftp.example.com
Donwloading: curl -u account@website.com:password -O ftp://ftp.example.com/ftp_file.txt
Show req/res headers:
curl -i http://www.example.com/posts/3
Fallow Redirection:
curl -L http://www.example.com/posts/3
Output:
[verbose] curl -v http://www.example.com/posts/3
[Too Verbose] curl -vv http://www.example.com/posts/3
[silent] curl -s http://www.example.com/posts/3
User Agent
curl -A "User Agent String" http://www.example.com/posts/3
Adding Cookies to Requests
curl -b name=value http://www.example.com/posts/3
Adding Cookies to Requests from file
curl -b cookies.txt http://www.example.com/posts/3
Adding Custom Headers to Requests
curl -H "Header:Value" http://www.example.com/posts/3
Use Compression [deflate/gzip]
curl --compressed http://www.example.com/posts/3
Save response to file
curl -o results.txt http://www.example.com/posts/3