package fetcher
import "github.com/theupdateframework/go-tuf/v2/metadata/fetcher"
Index ¶
- type DefaultFetcher
- func NewDefaultFetcher() *DefaultFetcher
- func (d *DefaultFetcher) DownloadFile(urlPath string, maxLength int64, _ time.Duration) ([]byte, error)
- func (f *DefaultFetcher) NewFetcherWithHTTPClient(hc httpClient) *DefaultFetcher
- func (f *DefaultFetcher) NewFetcherWithRoundTripper(rt http.RoundTripper) *DefaultFetcher
- func (f *DefaultFetcher) SetHTTPClient(hc httpClient)
- func (d *DefaultFetcher) SetHTTPUserAgent(httpUserAgent string)
- func (f *DefaultFetcher) SetRetry(retryInterval time.Duration, retryCount uint)
- func (f *DefaultFetcher) SetRetryOptions(retryOptions ...backoff.RetryOption)
- func (f *DefaultFetcher) SetTransport(rt http.RoundTripper) error
- type Fetcher
Types ¶
type DefaultFetcher ¶
type DefaultFetcher struct {
// contains filtered or unexported fields
}
DefaultFetcher implements Fetcher
func NewDefaultFetcher ¶
func NewDefaultFetcher() *DefaultFetcher
func (*DefaultFetcher) DownloadFile ¶
func (d *DefaultFetcher) DownloadFile(urlPath string, maxLength int64, _ time.Duration) ([]byte, error)
DownloadFile downloads a file from urlPath, errors out if it failed, its length is larger than maxLength or the timeout is reached.
func (*DefaultFetcher) NewFetcherWithHTTPClient ¶
func (f *DefaultFetcher) NewFetcherWithHTTPClient(hc httpClient) *DefaultFetcher
NewFetcherWithHTTPClient creates a new DefaultFetcher with a custom httpClient
func (*DefaultFetcher) NewFetcherWithRoundTripper ¶
func (f *DefaultFetcher) NewFetcherWithRoundTripper(rt http.RoundTripper) *DefaultFetcher
NewFetcherWithRoundTripper creates a new DefaultFetcher with a custom RoundTripper The function will create a default http.Client and replace the transport with the provided RoundTripper implementation
func (*DefaultFetcher) SetHTTPClient ¶
func (f *DefaultFetcher) SetHTTPClient(hc httpClient)
func (*DefaultFetcher) SetHTTPUserAgent ¶
func (d *DefaultFetcher) SetHTTPUserAgent(httpUserAgent string)
func (*DefaultFetcher) SetRetry ¶
func (f *DefaultFetcher) SetRetry(retryInterval time.Duration, retryCount uint)
func (*DefaultFetcher) SetRetryOptions ¶
func (f *DefaultFetcher) SetRetryOptions(retryOptions ...backoff.RetryOption)
func (*DefaultFetcher) SetTransport ¶
func (f *DefaultFetcher) SetTransport(rt http.RoundTripper) error
type Fetcher ¶
type Fetcher interface {
// DownloadFile downloads a file from the provided URL, reading
// up to maxLength of bytes before it aborts.
// The timeout argument is deprecated and not used. To configure
// the timeout (or retries), modify the fetcher instead. For the
// DefaultFetcher the underlying HTTP client can be substituted.
DownloadFile(urlPath string, maxLength int64, _ time.Duration) ([]byte, error)
}
Fetcher interface
Source Files ¶
- Version
- v2.4.1 (latest)
- Published
- Jan 26, 2026
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 2 seconds ago –
Tools for package owners.