utility

Bounded HTTP retry

Application policy, not a Bash-specific HTTP feature. Repeat only eligible read-only requests; bound attempts and individual transfers. Real retry loops need deadline, backoff, Retry-After and jitter. curl --retry counts additional retries, not total attempts; the fixture implements its own loop.

Formal Syntax & Structure

bash syntaxbash
for ((attempt=1; attempt<=LIMIT; attempt++)); do ...; done

Return Value

exit status

Application policy, not a Bash-specific HTTP feature. Repeat only eligible read-only requests; bound attempts and individual transfers. Real retry loops need deadline, backoff, Retry-After and jitter. curl --retry counts additional retries, not total attempts; the fixture implements its own loop.

Working Example

Example Snippetbash
[[ ${BM_API_BASE-} =~ ^http://127\.0\.0\.1:[0-9]{1,5}$ ]] || exit 2for ((attempt=1; attempt<=3; attempt++)); do    code=$(curl -q --noproxy "*" --proto "=http" -sS --connect-timeout 1 --max-time 2 -o body.json -w '%{http_code}' "$BM_API_BASE/retry") || exit 1    printf 'attempt=%s http=%s\n' "$attempt" "$code"    case $code in        200) jq -e '.ok == true' body.json >/dev/null || exit 2; exit 0;;        503) ;; # lab: no real delay        *) exit 2;;    esacdoneexit 1
Bash Reference