curl - GradedJestRisk/linux-training GitHub Wiki
curl
Setup
2 ways:
- curl configuration file
~/.curlrcfor each call; - environment variable for a single call.
Proxy
You can disable proxy with --noproxy
curl --noproxy '*' http://www.stackoverflow.com
.curlrc
proxy = 1.2.3.4
noproxy = .dev,localhost,127.0.0.1
Send a query
Send a PUT request (when a GET, omit --request)
curl --request PUT "http://localhost:3001/rnipp/person"
To get response code, add --show-headers.
To send a JSON in payload, use --data.
curl \
--header "Content-Type: application/json" \
--request PUT \
--data '{"username":"xyz","password":"xyz"}' \
$URL
In next version, you will use --json to omit --header option.
Failure
curl tries any query just one time, but you can ask him to keep trying.
Parameters:
retry: how much "times" he should tryretry-delay: rest time between triesretry-max-time: ceiling time
most operations in curl have no time-out by default
Parameters:
connect-timeout: to connectmax-time: to complete (will fail even if query is going on successfully)
https://everything.curl.dev/usingcurl/timeouts.html
write
write-out
Output response code and time elapsed
--write-out "%{http_code} - %{time_total}\n"