Versions in this module Expand all Collapse all v3 v3.1.1 Jul 19, 2026 v3.1.0 Jul 18, 2026 Changes in this version + func ContextWithDefaultTimeout(ctx context.Context, def time.Duration) (context.Context, context.CancelFunc) v3.0.0 Jul 17, 2026 Changes in this version + const DefaultBaseDelay + const DefaultMaxAttempts + const DefaultMaxBodyBytes + const RetryAfterCap + var ErrNoCertsInPEM = errors.New("httpx: no PEM-encoded certificates found") + var ErrRateLimited = errors.New("rate limited") + var ErrServerError = errors.New("server error") + func CATransport(pem []byte) (*http.Transport, error) + func CheckHTTPStatus(resp *http.Response) error + func CloneDefaultTransport() (*http.Transport, error) + func Close(c *http.Client) + func DefaultRedirectPolicy(req *http.Request, via []*http.Request) error + func Do[T any](ctx context.Context, fn func(ctx context.Context) (T, error), opts ...DoOption) (T, error) + func DockerGitHubRedirectPolicy(req *http.Request, via []*http.Request) error + func Drain(body io.ReadCloser) + func DrainClose(rc io.ReadCloser) + func GetBytes(ctx context.Context, client *http.Client, reqURL string, opts ...GetOption) ([]byte, error) + 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 LogSafeError(err error) error + func NewClient(timeout time.Duration) *http.Client + func NewRetryClient(base http.RoundTripper, policy CheckRedirect, cfg TransportConfig) *http.Client + func ParseRetryAfter(h string) time.Duration + func ParseRetryAfterResponse(resp *http.Response) time.Duration + func Permanent(err error) error + func ReadLimitedBody(body io.ReadCloser, limit int64) ([]byte, error) + func RedactSecret(err error, secret string) error + func RedactSecretString(s, secret string) string + func RedactTransportError(err error, prefix, secret string) error + func RedirectPolicyFunc(opts ...RedirectOption) func(*http.Request, []*http.Request) error + func RefuseAllRedirects(*http.Request, []*http.Request) 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 CheckRedirect = func(req *http.Request, via []*http.Request) error + type CheckRetry func(ctx context.Context, resp *http.Response, err error) (bool, error) + type ConditionalResult struct + Body []byte + NotModified bool + Validators Validators + func DoConditional(client *http.Client, req *http.Request, v Validators, maxBodyBytes int64) (ConditionalResult, error) + type DoOption interface + func WithLabel(s string) DoOption + func WithRateLimitOnly(maxWait time.Duration) DoOption + func WithRateLimitRetry(maxWait time.Duration) DoOption + type GetOption interface + func WithHeaders(fn func(*http.Request)) GetOption + func WithMaxBodyBytes(n int64) GetOption + 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 interface + func WithBaseDelay(d time.Duration) Option + func WithLogger(l *slog.Logger) Option + func WithMaxAttempts(n int) 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 RateLimitError struct + Msg string + RetryAfter time.Duration + func (e *RateLimitError) Error() string + type RedirectOption func(*redirectCfg) + func WithAllowSchemeDowngrade(allow bool) RedirectOption + func WithAllowedHosts(hosts ...string) RedirectOption + func WithAllowedSuffixes(suffixes ...string) RedirectOption + func WithMaxHops(n int) RedirectOption + func WithSameHost() RedirectOption + type ResponseTooLargeError struct + Limit int64 + func (e *ResponseTooLargeError) Error() string + type RetryAfterHint interface + RetryAfterHint func() time.Duration + type RetryRoundTripper struct + func NewRetryRoundTripper(next http.RoundTripper, cfg TransportConfig) *RetryRoundTripper + func (rt *RetryRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) + 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 + type TransportConfig struct + BaseDelay time.Duration + CheckRetry CheckRetry + MaxAttempts int + MaxElapsedTime time.Duration + OnRetry OnRetry + PrepareRetry PrepareRetry + RetryNonIdempotent bool + type Validators struct + ETag string + LastModified string Other modules containing this package github.com/cplieger/httpx github.com/cplieger/httpx/v2