Closed Two-Hearts closed 5 months ago
It is a mock issue and the mock should use Header.Set()
for a proper setup. In the real world, OCI-Subject
header key returned by the server is transformed into Oci-Subject
by the built-in golang http
library.
It might be more of an enhancement than a bug, but under function
checkOCISubjectHeader
, it says:Although defined by distribution-spec, "OCI-Subject" is actually not a valid key for
http.Response.Header
. Keys inhttp.Response.Header
are canonicalized. Therefore, given the belowhttp response
:checkOCISubjectHeader
will not runs.repo.SetReferrersCapability(true)
. And hence, not marking the registry as supporting the Referrers API. This is caused by oras-go directly getting the response header throughresp.Header.Get("OCI-Subject")
, which then searches forCanonicalMIMEHeaderKey
ofOCI-Subject
, i.e.Oci-Subject
, and this header is not in the abovehttp.Response
.What's expected: As described by distribution-spec v1.1.0-rc4: https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc4/spec.md#pushing-manifests-with-subject, when response header
OCI-Subject
is present,s.repo.SetReferrersCapability(true)
should be run.Alternative: Update the comment stating that caller SHOULD use the
http.response.Header.Set()
method to set theOCI-Subject
header.