diff --git a/endpoints/v2/manifest.py b/endpoints/v2/manifest.py index 37ea12953..a463f2866 100644 --- a/endpoints/v2/manifest.py +++ b/endpoints/v2/manifest.py @@ -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, }) diff --git a/test/registry/protocol_v2.py b/test/registry/protocol_v2.py index 01e8f12c6..405d3be4c 100644 --- a/test/registry/protocol_v2.py +++ b/test/registry/protocol_v2.py @@ -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