Skip to content

Commit

Permalink
feature(httpReadFile): Add headers to download from github release as…
Browse files Browse the repository at this point in the history
…sets (#4826)
  • Loading branch information
Googlom authored Feb 20, 2024
1 parent bdc49e7 commit 150560d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,13 @@ func httpReadFile(name string, accessTokens map[string]string) (io.ReadCloser, e
var header http.Header
if len(accessTokens[u.Host]) > 0 {
client.SetOptions(piperhttp.ClientOptions{Token: fmt.Sprintf("token %v", accessTokens[u.Host])})
header = map[string][]string{"Accept": {"application/vnd.github.v3.raw"}}
if strings.Contains(u.Path, "releases/assets") {
// Assets download endpoint requires 'application/octet-stream' media type.
// See: https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#get-a-release-asset
header = map[string][]string{"Accept": {"application/octet-stream"}}
} else {
header = map[string][]string{"Accept": {"application/vnd.github.v3.raw"}}
}
}

response, err := client.SendRequest("GET", name, nil, header, nil)
Expand Down

0 comments on commit 150560d

Please sign in to comment.