### Basic Syntax ```bash curl [option] [URL] ``` ### Making Requests #### 1. GET Request ```bash curl http://example.com ``` #### 2. POST Request ```bash curl -X POST -d "key1=value1&key2=value2" http://example.com ``` #### 3. PUT Request ```bash curl -X PUT -d "key1=value1" http://example.com/resource/1 ``` #### 4. DELETE Request ```bash curl -X DELETE http://example.com/resource/1 ``` ### Headers #### - Send Headers ```bash curl -H "Authorization: Bearer TOKEN" http://example.com ``` #### - Custom User-Agent ```bash curl -A "MyUserAgent" http://example.com ``` ### Data #### - Send JSON Data The `-d` indicates a POST ```bash curl -H "Content-Type: application/json" -d '{"key":"value"}' http://example.com ``` #### - Send Data from File ```bash curl -d "@filename.txt" http://example.com ``` ### File Operations #### - Download File ```bash curl -O http://example.com/file.jpg ``` #### - Upload File (FTP) ```bash curl -T file.jpg ftp://example.com --user username:password ``` ### Miscellaneous #### - Follow Redirects ```bash curl -L http://example.com ``` #### - Verbose Output ```bash curl -v http://example.com ``` #### - Save Output to File ```bash curl http://example.com > output.html ``` #### - Basic Authentication ```bash curl -u username:password http://example.com ``` #### - Cookies - **Save Cookies** ```bash curl -c cookies.txt http://example.com ``` - **Use Saved Cookies** ```bash curl -b cookies.txt http://example.com ``` #### - Show Header Information (`-i` flag) ```bash curl -i http://example.com ``` - Use this flag to include the HTTP header in the output. It can be useful for debugging or when you need to see header information along with the body content.