# `Foundation.Retry.HTTP`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L1)

HTTP retry helpers with generic status, method, and Retry-After parsing helpers.

Provides retry delay calculation, status classification, and Retry-After parsing.

# `headers`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L47)

```elixir
@type headers() :: [{String.t(), String.t()}] | map()
```

# `method`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L48)

```elixir
@type method() :: atom() | String.t()
```

# `retryable_statuses_by_method`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L49)

```elixir
@type retryable_statuses_by_method() ::
  keyword([integer()]) | %{optional(method() | :all) =&gt; [integer()]}
```

# `parse_retry_after`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L114)

```elixir
@spec parse_retry_after(headers(), non_neg_integer()) :: non_neg_integer()
```

Parse Retry-After headers into milliseconds.

Supports:
  * `retry-after-ms` - milliseconds
  * `retry-after` - delta-seconds
  * `retry-after` - HTTP-date

# `retry_delay`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L56)

```elixir
@spec retry_delay(non_neg_integer()) :: non_neg_integer()
```

Calculate the retry delay for the given attempt.

# `retry_delay`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L64)

```elixir
@spec retry_delay(non_neg_integer(), pos_integer(), pos_integer()) ::
  non_neg_integer()
```

Calculate the retry delay with custom initial and max delays.

# `retryable_status?`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L79)

```elixir
@spec retryable_status?(integer()) :: boolean()
```

Determine whether a status code is retryable.

# `retryable_status_for_method?`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L93)

```elixir
@spec retryable_status_for_method?(
  integer(),
  method(),
  retryable_statuses_by_method()
) :: boolean()
```

Determine whether a status code is retryable for the given method under
caller-provided method rules.

Rules may be provided as a map or keyword list keyed by HTTP method or `:all`.

# `should_retry?`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L122)

```elixir
@spec should_retry?(map() | {integer(), headers()} | integer()) :: boolean()
```

Decide whether a response should be retried based on headers and status.

# `should_retry_for_method?`
[🔗](https://github.com/nshkrdotcom/foundation/blob/v0.2.1/lib/foundation/retry/http.ex#L146)

```elixir
@spec should_retry_for_method?(
  method(),
  map() | {integer(), headers()} | integer(),
  retryable_statuses_by_method()
) :: boolean()
```

Decide whether a response should be retried based on the given method, headers,
and caller-provided method rules.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
