Documentation
¶
Overview ¶
Package httputil provides a thin HTTP+JSON helper for providers.
Index ¶
Constants ¶
View Source
const DefaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
DefaultUserAgent is sent on every request unless the caller explicitly sets a User-Agent header. Go's default "Go-http-client/1.1" gets blocked by Cloudflare, so we use a real browser UA.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
Error is returned for non-2xx HTTP responses.
func (*Error) RetryAfter ¶ added in v0.5.0
RetryAfter returns the absolute time the server asked us to wait until before retrying, parsed from common rate-limit / server-busy response headers. Returns zero-time when no recognized hint is present or the status code isn't one that should carry one.
Recognized headers, in order of preference:
- Retry-After (RFC 7231: seconds OR HTTP date)
- x-ratelimit-reset (Unix timestamp OR seconds-from-now)
- anthropic-ratelimit-requests-reset (ISO 8601)
- anthropic-ratelimit-tokens-reset (ISO 8601)
Click to show internal directories.
Click to hide internal directories.