Versions in this module Expand all Collapse all v1 v1.1.0 Jun 16, 2026 Changes in this version type RTOption + func WithBackoffFunc(f func() Backoff) RTOption v1.0.7 Jun 15, 2026 v1.0.6 Jun 15, 2026 v1.0.5 Jun 15, 2026 v1.0.4 Jun 10, 2026 v1.0.3 Jun 8, 2026 v1.0.2 Jun 4, 2026 v1.0.1 Jun 4, 2026 v1.0.0 Jun 3, 2026 Changes in this version + const BackoffStop + const DefaultBaseDelay + const DefaultMaxAttempts + const DefaultMaxBodyBytes + const RetryAfterCap + var ErrRateLimited = errors.New("rate limited") + var ErrServerError = errors.New("server error") + var RedirectPolicy = DockerGitHubRedirectPolicy + func CheckHTTPStatus(resp *http.Response) error + func Close(c *http.Client) + func DefaultRedirectPolicy(req *http.Request, via []*http.Request) error + func DockerGitHubRedirectPolicy(req *http.Request, via []*http.Request) error + func Drain(body io.ReadCloser) + func DrainClose(rc io.ReadCloser) + func IsPermanent(err error) bool + func IsTransient(err error) bool + func JitteredBackoff(backoff time.Duration) time.Duration + func LimitedBody(resp *http.Response, limit int64) io.ReadCloser + func NewClient(timeout time.Duration) *http.Client + func ParseRetryAfter(h string) time.Duration + func ParseRetryAfterResponse(resp *http.Response) time.Duration + func Permanent(err error) error + func RedactSecret(err error, secret string) error + func RedactTransportError(err error, prefix, secret string) error + func RedirectPolicyFunc(opts ...RedirectOption) func(*http.Request, []*http.Request) error + func Retry(ctx context.Context, client *http.Client, reqURL string, opts ...Option) ([]byte, error) + func RetryOnRateLimit(ctx context.Context, maxAttempts int, maxWait time.Duration, ...) error + func RetryWithBackoff[T any](ctx context.Context, maxRetries int, baseDelay time.Duration, label string, ...) (T, error) + func SafeDouble(d time.Duration) time.Duration + func SleepCtx(ctx context.Context, d time.Duration) error + type AuthError struct + Msg string + func (e *AuthError) Error() string + type Backoff interface + NextBackOff func() time.Duration + Reset func() + type CheckRetry func(ctx context.Context, resp *http.Response, err error) (bool, error) + type ExpBackoffOption func(*expBackoffCfg) + func WithInitialInterval(d time.Duration) ExpBackoffOption + func WithMaxElapsedTime(d time.Duration) ExpBackoffOption + type ExponentialBackoff struct + func NewExponentialBackoff(opts ...ExpBackoffOption) *ExponentialBackoff + func (b *ExponentialBackoff) NextBackOff() time.Duration + func (b *ExponentialBackoff) Reset() + type HTTPStatusError struct + Code int + func (e *HTTPStatusError) Error() string + func (e *HTTPStatusError) IsClientError() bool + func (e *HTTPStatusError) IsServerError() bool + func (e *HTTPStatusError) IsTransient() bool + type OnRetry func(attempt int, req *http.Request, resp *http.Response, err error) + type Option func(*retryCfg) + func WithBaseDelay(d time.Duration) Option + func WithHeaders(fn func(*http.Request)) Option + func WithLogger(l *slog.Logger) Option + func WithMaxAttempts(n int) Option + func WithMaxBodyBytes(n int64) Option + type PermanentError struct + Err error + func (e *PermanentError) Error() string + func (e *PermanentError) Is(target error) bool + func (e *PermanentError) Unwrap() error + type PrepareRetry func(req *http.Request) error + type RTOption func(*rtCfg) + func WithBackoff(b Backoff) RTOption + func WithCheckRetry(cr CheckRetry) RTOption + func WithMaxRetries(n int) RTOption + func WithOnRetry(fn OnRetry) RTOption + func WithPrepareRetry(fn PrepareRetry) RTOption + func WithRTBaseDelay(d time.Duration) RTOption + func WithRTMaxElapsedTime(d time.Duration) RTOption + func WithRetryNonIdempotent(enable bool) RTOption + type RateLimitError struct + Msg string + RetryAfter time.Duration + func (e *RateLimitError) Error() string + type RedirectOption func(*redirectCfg) + func WithAllowedHosts(hosts ...string) RedirectOption + func WithAllowedSuffixes(suffixes ...string) RedirectOption + func WithMaxHops(n int) RedirectOption + type RetryRoundTripper struct + func NewRetryRoundTripper(next http.RoundTripper, opts ...RTOption) *RetryRoundTripper + func (rt *RetryRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) + func (rt *RetryRoundTripper) StandardClient() *http.Client + type StatusError struct + Code int + URL string + func (e *StatusError) Error() string + func (e *StatusError) Is(target error) bool + type Transient interface + IsTransient func() bool Other modules containing this package github.com/cplieger/httpx/v2