@ -45,6 +45,7 @@ type options struct {
registryClient * registry . Client
registryClient * registry . Client
timeout time . Duration
timeout time . Duration
transport * http . Transport
transport * http . Transport
ifModifiedSince * time . Time
}
}
// Option allows specifying various settings configurable by the user for overriding the defaults
// Option allows specifying various settings configurable by the user for overriding the defaults
@ -121,6 +122,20 @@ func WithUntar() Option {
}
}
}
}
// WithIfModifiedSince leverages the HTTP caching mechanism
// defined on RFC7234 4.3.2. It prevents the HTTP getter from
// downloading index that haven't been modified based on `since`.
// If the file was not modified, getter will return a
// `304 Not Modified`, as per RFC.
//
// The caller is responsible for caching previously downloaded
// index files and handling the returning error.
func WithIfModifiedSince ( since time . Time ) Option {
return func ( opts * options ) {
opts . ifModifiedSince = & since
}
}
// WithTransport sets the http.Transport to allow overwriting the HTTPGetter default.
// WithTransport sets the http.Transport to allow overwriting the HTTPGetter default.
func WithTransport ( transport * http . Transport ) Option {
func WithTransport ( transport * http . Transport ) Option {
return func ( opts * options ) {
return func ( opts * options ) {