From 5abb6219c8d9356fbf645f601fe9ea826b547ec3 Mon Sep 17 00:00:00 2001 From: Zach Steindler Date: Tue, 25 Jun 2024 15:57:13 -0400 Subject: [PATCH] Add the ability to customize the HTTP user agent To help with things like https://github.com/sigstore/sigstore-go/issues/143 Signed-off-by: Zach Steindler --- metadata/fetcher/fetcher.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/metadata/fetcher/fetcher.go b/metadata/fetcher/fetcher.go index 6eb36094..dfe2bc14 100644 --- a/metadata/fetcher/fetcher.go +++ b/metadata/fetcher/fetcher.go @@ -37,6 +37,10 @@ type DefaultFetcher struct { httpUserAgent string } +func (d *DefaultFetcher) SetHTTPUserAgent(httpUserAgent string) { + d.httpUserAgent = httpUserAgent +} + // DownloadFile downloads a file from urlPath, errors out if it failed, // its length is larger than maxLength or the timeout is reached. func (d *DefaultFetcher) DownloadFile(urlPath string, maxLength int64, timeout time.Duration) ([]byte, error) {