Skip to content

Commit fff3547

Browse files
committedMay 14, 2024··
ISSUE-9507: ADD application/gzip,application/octet-stream accept header when downloading chart
Signed-off-by: Matt Clegg <m@cle.gg>
1 parent 7a77824 commit fff3547

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
 

‎pkg/downloader/chart_downloader.go

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *proven
9797
return "", nil, err
9898
}
9999

100+
c.Options = append(c.Options, getter.WithAcceptHeader("application/gzip,application/octet-stream"))
101+
100102
data, err := g.Get(u.String(), c.Options...)
101103
if err != nil {
102104
return "", nil, err

‎pkg/getter/getter.go

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type options struct {
3838
unTar bool
3939
insecureSkipVerifyTLS bool
4040
plainHTTP bool
41+
acceptHeader string
4142
username string
4243
password string
4344
passCredentialsAll bool
@@ -60,6 +61,13 @@ func WithURL(url string) Option {
6061
}
6162
}
6263

64+
// WithAcceptHeader sets the request's Accept header as some REST APIs serve multiple content types
65+
func WithAcceptHeader(header string) Option {
66+
return func(opts *options) {
67+
opts.acceptHeader = header
68+
}
69+
}
70+
6371
// WithBasicAuth sets the request's Authorization header to use the provided credentials
6472
func WithBasicAuth(username, password string) Option {
6573
return func(opts *options) {

‎pkg/getter/httpgetter.go

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func (g *HTTPGetter) get(href string) (*bytes.Buffer, error) {
5353
return nil, err
5454
}
5555

56+
if g.opts.acceptHeader != "" {
57+
req.Header.Set("Accept", g.opts.acceptHeader)
58+
}
59+
5660
req.Header.Set("User-Agent", version.GetUserAgent())
5761
if g.opts.userAgent != "" {
5862
req.Header.Set("User-Agent", g.opts.userAgent)

0 commit comments

Comments
 (0)
Please sign in to comment.