cURL command line utility
curl recipes
Determine HTTP status (200, 404, etc.) with --write-out '%{http_code}'
--write-out '%{http_code}'
health-probe.sh
results in Azure: 200
.
Send some XML via POST to a URL
Read body to upload from STDIN (via --data @-
)
--data @-
)POST-XML.sh
Read body to upload from file
POST-XML.sh
Tracing your cURL calls with Fiddler
When I want to completely see the traffic originating from my cURL instance, I use Fiddler (a Windows-based HTTP(s)-proxy GUI). Fiddler can be configured to decrypt TLS (https://) traffic, but that means that the server certificate for cURL will be untrusted. The following args instruct cURL to use a local (untrusted) HTTPs-proxy:
curl-use-fiddler.sh
Extract both custom HTTP header values and the body from a request
The following script uses cURL to fetch a web page, and then extracts both an HTTP from the response headers, as well as the body.
This script uses awk,
which creates temporary files to store header and body part.
Links
Last updated