From a2c34808a515a45c707464daeaa3831bae31e058 Mon Sep 17 00:00:00 2001 From: peusebiu Date: Tue, 21 Mar 2023 19:27:49 +0200 Subject: [PATCH] fix(http): fix GET requests to use 'Accept' header (#1288) use 'Accept' header instead of 'Content-Type' use 'Authorization' header only if we have credentials Signed-off-by: Petu Eusebiu --- pkg/common/common.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/common/common.go b/pkg/common/common.go index 60e7979e..df1f809f 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -147,9 +147,11 @@ func MakeHTTPGetRequest(httpClient *http.Client, username string, password strin return nil, 0, err } - req.Header.Set("Content-Type", mediaType) + req.Header.Set("Accept", mediaType) - req.SetBasicAuth(username, password) + if username != "" && password != "" { + req.SetBasicAuth(username, password) + } resp, err := httpClient.Do(req) if err != nil {