From 1d4a18f7de937f8f0642cce2528aadfbb92e00c7 Mon Sep 17 00:00:00 2001 From: gregoireW <24318548+GregoireW@users.noreply.github.com> Date: Fri, 28 Jun 2024 21:15:03 +0200 Subject: [PATCH] Referrer API must return correct Content-Type As per the spec, Content-Type header MUST be set to application/vnd.oci.image.index.v1+json This is important as GAR today (OCI 1.0) redirect "referrers" API call to the authentication page, and doing so the call return 200 OK + content-type: text/html. --- pkg/v1/remote/referrers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/v1/remote/referrers.go b/pkg/v1/remote/referrers.go index e30ca57ed..48e3835f9 100644 --- a/pkg/v1/remote/referrers.go +++ b/pkg/v1/remote/referrers.go @@ -66,7 +66,7 @@ func (f *fetcher) fetchReferrers(ctx context.Context, filter map[string]string, } var b []byte - if resp.StatusCode == http.StatusOK { + if resp.StatusCode == http.StatusOK && resp.Header.Get("Content-Type") == string(types.OCIImageIndex) { b, err = io.ReadAll(resp.Body) if err != nil { return nil, err