curl tricks
Timeout
User-agent
CURL_USERAGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"
test -n "$CURL_USERAGENT" && curl_useragent="-A $CURL_USERAGENT"
curl $curl_useragent <URL>
proxy
As option
sock5
http
As env
Send multi-line message by json
name="foo"
message="$@"
message="${message//$'\r'/}"
message="${message//$'\n'/\\n}"
json="{'message':'${message}','name':'$name'}"
json=$(echo "$json" | tr "'" '"')
curl -s -X POST -H "Content-Type: application/json" "$URL" -d "$json"
Basic Authorization
U='YOUR-NAME'
P='YOUR-PASSWORD'
A=$(echo -ne "$U:$P"|base64 --wrap 0)
curl --header "Authorization: Basic $A" http://foo.com/