Documentation
¶
Overview ¶
Package reghttp is used for HTTP requests to a registry
Index ¶
- Constants
- func HTTPError(statusCode int) error
- type Client
- type Opts
- func WithCertDirs(dirs []string) Opts
- func WithCertFiles(files []string) Opts
- func WithCerts(certs [][]byte) Opts
- func WithConfigHostFn(gch func(string) *config.Host) Opts
- func WithDelay(delayInit time.Duration, delayMax time.Duration) Opts
- func WithHTTPClient(hc *http.Client) Opts
- func WithLog(log *logrus.Logger) Opts
- func WithRetryLimit(rl int) Opts
- func WithTransport(t *http.Transport) Opts
- func WithUserAgent(ua string) Opts
- type Req
- type Resp
Constants ¶
const (
DefaultRetryLimit = 5 // number of times a request will be retried
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client wrapper. It handles features like authentication, retries, backoff delays, TLS settings.
func (*Client) GetThrottle ¶ added in v0.7.2
GetThrottle returns the current pqueue.Queue for a host used to throttle connections. This can be used to acquire multiple throttles before performing a request across multiple hosts.
type Opts ¶
type Opts func(*Client)
Opts is used to configure client options.
func WithCertDirs ¶
WithCertDirs adds directories to check for host specific certs.
func WithCertFiles ¶
WithCertFiles adds certificates by filename.
func WithConfigHostFn ¶ added in v0.7.2
WithConfigHostFn adds the callback to request a config.Host struct. The function must normalize the hostname for Docker Hub support.
func WithDelay ¶
WithDelay initial time to wait between retries (increased with exponential backoff).
func WithHTTPClient ¶
WithHTTPClient uses a specific http client with retryable requests.
func WithRetryLimit ¶
WithRetryLimit restricts the number of retries (defaults to 5).
func WithTransport ¶
WithTransport uses a specific http transport with retryable requests.
type Req ¶
type Req struct {
MetaKind reqmeta.Kind // kind of request for the priority queue
Host string // registry name, hostname and mirrors will be looked up from host configuration
Method string // http method to call
DirectURL *url.URL // url to query, overrides repository, path, and query
Repository string // repository to scope the request
Path string // path of the request within a repository
Query url.Values // url query parameters
BodyLen int64 // length of body to send
BodyBytes []byte // bytes of the body, overridden by BodyFunc
BodyFunc func() (io.ReadCloser, error) // function to return a new body
Headers http.Header // headers to send in the request
NoPrefix bool // do not include the repository prefix
NoMirrors bool // do not send request to a mirror
ExpectLen int64 // expected size of the returned body
TransactLen int64 // size of an overall transaction for the priority queue
IgnoreErr bool // ignore http errors and do not trigger backoffs
}
Req is a request to send to a registry.
type Resp ¶
type Resp struct {
// contains filtered or unexported fields
}
Resp is used to handle the result of a request.
func (*Resp) HTTPResponse ¶
HTTPResponse returns the http.Response from the last request.