From 3da0ee00d87932eb7d32d8c61b8e0e2631a1909d Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Mon, 18 Jan 2016 09:59:50 -0800 Subject: [PATCH] Do not require "charset=utf-8" for a schema1 with content type application/json For compatibility with other registries that don't use this exact variant of the Content-Type header, we need to be more flexible about what we accept. Any form of "application/json" should be allowed. The charset should not be included in the comparison. See docker/docker#19400. Signed-off-by: Aaron Lehmann --- docs/handlers/api_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/handlers/api_test.go b/docs/handlers/api_test.go index a1aac3cd..f3f5a4fb 100644 --- a/docs/handlers/api_test.go +++ b/docs/handlers/api_test.go @@ -954,7 +954,14 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName string) manife } - resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, "", sm2) + // Re-push with a few different Content-Types. The official schema1 + // content type should work, as should application/json with/without a + // charset. + resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, schema1.MediaTypeManifest, sm2) + checkResponse(t, "re-putting signed manifest", resp, http.StatusCreated) + resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, "application/json; charset=utf-8", sm2) + checkResponse(t, "re-putting signed manifest", resp, http.StatusCreated) + resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, "application/json", sm2) checkResponse(t, "re-putting signed manifest", resp, http.StatusCreated) resp, err = http.Get(manifestDigestURL)