|
|
|
Shell can make HTTP requests using |
|
|
Check if curl is available: |
|
|
Basic GET request: |
|
|
The -s flag suppresses progress output. |
|
|
Save response to file: |
|
|
Get only HTTP status code: |
|
|
GET with query parameters: |
|
|
Or use –data-urlencode for encoding: |
|
|
POST request with form data: |
|
|
POST with JSON: |
|
|
Custom headers: |
|
|
Follow redirects with -L: |
|
|
Set timeout: |
|
|
Download file: |
|
|
Resume download with -C -: curl -C - -O “https://example.com/large-file.zip” |
|
|
Basic authentication: |
|
|
Bearer token authentication: |
|
|
PUT request: |
|
|
DELETE request: |
|
|
PATCH request: |
|
|
Upload file: |
|
|
Response headers: |
|
|
Both headers and body: |
|
|
Using wget as an alternative to curl: |
|
|
Retry on failure: |
|
|
Check if URL is accessible: |
|
|
Parse JSON response: |
|
|
Send cookies: |
|
|
Save and send cookies: |
|
|
Verbose output for debugging: |
|
|
HTTPS with certificate verification: |
|
|
curl –cacert /path/to/ca.crt “https://secure-server.example” |
|
|
Rate limiting (pause between requests): |
|
|
Parallel requests with xargs: |
|
|
Handle errors: |
|