From f12b7b4bc21ff6a64505909a9ba49107877d2ca4 Mon Sep 17 00:00:00 2001 From: Vladimir Bulyga Date: Sat, 1 Nov 2014 19:22:28 +0300 Subject: [PATCH] allow to use x-registry-auth header with enabled cors Signed-off-by: Vladimir Bulyga --- api/server/server.go | 2 +- integration/api_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/server/server.go b/api/server/server.go index d77a6c22a2..16e5085148 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -1167,7 +1167,7 @@ func optionsHandler(eng *engine.Engine, version version.Version, w http.Response } func writeCorsHeaders(w http.ResponseWriter, r *http.Request) { w.Header().Add("Access-Control-Allow-Origin", "*") - w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") + w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth") w.Header().Add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS") } diff --git a/integration/api_test.go b/integration/api_test.go index 6bb340d53b..8e45f89282 100644 --- a/integration/api_test.go +++ b/integration/api_test.go @@ -785,8 +785,8 @@ func TestGetEnabledCors(t *testing.T) { if allowOrigin != "*" { t.Errorf("Expected header Access-Control-Allow-Origin to be \"*\", %s found.", allowOrigin) } - if allowHeaders != "Origin, X-Requested-With, Content-Type, Accept" { - t.Errorf("Expected header Access-Control-Allow-Headers to be \"Origin, X-Requested-With, Content-Type, Accept\", %s found.", allowHeaders) + if allowHeaders != "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth" { + t.Errorf("Expected header Access-Control-Allow-Headers to be \"Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth\", %s found.", allowHeaders) } if allowMethods != "GET, POST, DELETE, PUT, OPTIONS" { t.Errorf("Expected hearder Access-Control-Allow-Methods to be \"GET, POST, DELETE, PUT, OPTIONS\", %s found.", allowMethods)