Versions in this module Expand all Collapse all v2 v2.6.0 Jul 15, 2026 Changes in this version + type ConditionalResult struct + Body []byte + NotModified bool + Validators Validators + func DoConditional(client *http.Client, req *http.Request, v Validators, maxBodyBytes int64) (ConditionalResult, error) + type Validators struct + ETag string + LastModified string v2.5.0 Jul 14, 2026 Changes in this version + func CloneDefaultTransport() (*http.Transport, error) + func LogSafeError(err error) error + func RefuseAllRedirects(*http.Request, []*http.Request) error v2.4.0 Jul 10, 2026 v2.3.0 Jul 10, 2026 Changes in this version + func ReadLimitedBody(body io.ReadCloser, limit int64) ([]byte, error) + func RedactSecretString(s, secret string) string v2.2.0 Jul 9, 2026 Changes in this version type RedirectOption + func WithAllowSchemeDowngrade(allow bool) RedirectOption + func WithSameHost() RedirectOption + type RetryAfterHint interface + RetryAfterHint func() time.Duration v2.1.2 Jul 8, 2026 v2.1.1 Jul 5, 2026 v2.1.0 Jul 4, 2026 Changes in this version + var ErrNoCertsInPEM = errors.New("httpx: no PEM-encoded certificates found") + func CATransport(pem []byte) (*http.Transport, error) v2.0.2 Jun 29, 2026 v2.0.1 Jun 27, 2026 v2.0.0 Jun 25, 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") + 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, maxAttempts 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 WithBackoffFunc(f func() Backoff) RTOption + func WithCheckRetry(cr CheckRetry) RTOption + func WithOnRetry(fn OnRetry) RTOption + func WithPrepareRetry(fn PrepareRetry) RTOption + func WithRTBaseDelay(d time.Duration) RTOption + func WithRTMaxAttempts(n int) 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 ResponseTooLargeError struct + Limit int64 + func (e *ResponseTooLargeError) Error() string + 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