From af330132fcea8f059bfdd5850f601bddf6eb92b4 Mon Sep 17 00:00:00 2001 From: Josh Dolitsky Date: Mon, 31 Jul 2023 09:31:44 -0500 Subject: [PATCH] Return OCI Index content-type for referrers response Signed-off-by: Josh Dolitsky --- pkg/registry/manifest.go | 1 + pkg/registry/registry_test.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pkg/registry/manifest.go b/pkg/registry/manifest.go index 4e02eeed7..db8a8dc69 100644 --- a/pkg/registry/manifest.go +++ b/pkg/registry/manifest.go @@ -437,6 +437,7 @@ func (m *manifests) handleReferrers(resp http.ResponseWriter, req *http.Request) } msg, _ := json.Marshal(&im) resp.Header().Set("Content-Length", fmt.Sprint(len(msg))) + resp.Header().Set("Content-Type", string(types.OCIImageIndex)) resp.WriteHeader(http.StatusOK) io.Copy(resp, bytes.NewReader([]byte(msg))) return nil diff --git a/pkg/registry/registry_test.go b/pkg/registry/registry_test.go index 0ee492ed8..a9c257b56 100644 --- a/pkg/registry/registry_test.go +++ b/pkg/registry/registry_test.go @@ -446,6 +446,9 @@ func TestCalls(t *testing.T) { "foo/manifests/image": "foo", "foo/manifests/points-to-image": "{\"subject\": {\"digest\": \"sha256:" + sha256String("foo") + "\"}}", }, + Header: map[string]string{ + "Content-Type": "application/vnd.oci.image.index.v1+json", + }, }, { Description: "fetch references, subject pointing elsewhere", @@ -456,6 +459,9 @@ func TestCalls(t *testing.T) { "foo/manifests/image": "foo", "foo/manifests/points-to-image": "{\"subject\": {\"digest\": \"sha256:" + sha256String("nonexistant") + "\"}}", }, + Header: map[string]string{ + "Content-Type": "application/vnd.oci.image.index.v1+json", + }, }, { Description: "fetch references, no results", @@ -465,6 +471,9 @@ func TestCalls(t *testing.T) { Manifests: map[string]string{ "foo/manifests/image": "foo", }, + Header: map[string]string{ + "Content-Type": "application/vnd.oci.image.index.v1+json", + }, }, { Description: "fetch references, missing repo",