Remove the charset from the content type for manifests

This commit is contained in:
Joseph Schorr 2019-01-12 16:06:11 -05:00
parent a67d57b91c
commit 5b4d39daa4
2 changed files with 7 additions and 5 deletions

View file

@ -70,7 +70,7 @@ def fetch_manifest_by_tagname(namespace_name, repo_name, manifest_ref):
manifest_bytes.as_unicode(),
status=200,
headers={
'Content-Type': '%s; charset=utf-8' % manifest_media_type,
'Content-Type': manifest_media_type,
'Docker-Content-Digest': manifest_digest,
},
)
@ -99,7 +99,7 @@ def fetch_manifest_by_digest(namespace_name, repo_name, manifest_ref):
metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2', True])
return Response(manifest_bytes.as_unicode(), status=200, headers={
'Content-Type': '%s; charset=utf-8' % manifest_media_type,
'Content-Type': manifest_media_type,
'Docker-Content-Digest': manifest_digest,
})

View file

@ -168,7 +168,7 @@ class V2Protocol(RegistryProtocol):
return None
# Parse the returned manifest list and ensure it matches.
ct, _ = response.headers['Content-Type'].split(';', 1)
ct = response.headers['Content-Type']
assert ct == DOCKER_SCHEMA2_MANIFESTLIST_CONTENT_TYPE
retrieved = parse_manifest_from_bytes(Bytes.for_string_or_unicode(response.text), ct)
assert retrieved.schema_version == 2
@ -185,7 +185,8 @@ class V2Protocol(RegistryProtocol):
headers=headers)
if expected_failure is not None:
return None
ct, _ = response.headers['Content-Type'].split(';', 1)
ct = response.headers['Content-Type']
manifest = parse_manifest_from_bytes(Bytes.for_string_or_unicode(response.text), ct)
assert not manifest.is_manifest_list
assert manifest.digest == manifest_digest
@ -543,11 +544,12 @@ class V2Protocol(RegistryProtocol):
tag_name),
expected_status=(200, expected_failure, V2ProtocolSteps.GET_MANIFEST),
headers=headers)
response.encoding = 'utf-8'
if expected_failure is not None:
return None
# Ensure the manifest returned by us is valid.
ct, _ = response.headers['Content-Type'].split(';', 1)
ct = response.headers['Content-Type']
if not self.schema2:
assert ct in DOCKER_SCHEMA1_CONTENT_TYPES