From 85d1c214ccbc9f6be888f0bd7b12af157fc9518e Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Mon, 12 Dec 2022 16:33:26 +0100 Subject: [PATCH] Don't forward headers when making requests to package storage --- CHANGELOG.md | 1 + storage/resolver.go | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d76b9475..5d48f8717 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bugfixes * Fix internal server error when proxy mode is used and a package that doesn't exist is requested. [#925](https://github.com/elastic/package-registry/pull/925) +* Don't forward headers when requesting files from the package storage, just download them. [#935](https://github.com/elastic/package-registry/issues/935) ### Added diff --git a/storage/resolver.go b/storage/resolver.go index d3e93e29f..1769baf3b 100644 --- a/storage/resolver.go +++ b/storage/resolver.go @@ -29,7 +29,6 @@ func (resolver storageResolver) pipeRequestProxy(w http.ResponseWriter, r *http. client := &http.Client{} forwardRequest, err := http.NewRequestWithContext(r.Context(), r.Method, remoteURL, nil) - addRequestHeadersToRequest(r, forwardRequest) resp, err := client.Do(forwardRequest) if err != nil { @@ -52,14 +51,6 @@ func (resolver storageResolver) pipeRequestProxy(w http.ResponseWriter, r *http. return } -func addRequestHeadersToRequest(orig, forward *http.Request) { - for header, values := range orig.Header { - for _, value := range values { - forward.Header.Add(header, value) - } - } -} - func addRequestHeadersToResponse(w http.ResponseWriter, resp *http.Response) { for header, values := range resp.Header { if len(w.Header().Values(header)) > 0 {