utility-option
curl --header @file
Read headers from a file instead of passing expanded credential text in command arguments. Protect file permissions and cleanup, verify HTTPS for real secrets, restrict destination and avoid header dumps. Synthetic local header only.
Formal Syntax & Structure
bash syntaxbash
curl --header @FILE URLReturn Value
exit status
Read headers from a file instead of passing expanded credential text in command arguments. Protect file permissions and cleanup, verify HTTPS for real secrets, restrict destination and avoid header dumps. Synthetic local header only.
Working Example
Example Snippetbash
[[ ${BM_API_BASE-} =~ ^http://127\.0\.0\.1:[0-9]{1,5}$ ]] || exit 2umask 077trap 'rm -f -- headers.txt' EXITprintf '%s\n' 'Authorization: Bearer DEMO_ONLY' > headers.txt || exit 1code=$(curl -q --noproxy "*" --proto "=http" -sS --connect-timeout 1 --max-time 2 --header @headers.txt -o body.json -w '%{http_code}' "$BM_API_BASE/auth") || exit 1printf 'http=%s\n' "$code"[[ $code == 200 ]] && jq -e '.ok == true' body.json