0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

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 <peusebiu@cisco.com>
This commit is contained in:
peusebiu 2023-03-21 19:27:49 +02:00 committed by GitHub
parent c91d4a0308
commit a2c34808a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {