Browse code

Merge pull request #8905 from 13W/x-registry-auth

allow to use x-registry-auth header with enabled cors

Victor Vieux authored on 2014/11/19 10:21:22
Showing 2 changed files
... ...
@@ -1181,7 +1181,7 @@ func optionsHandler(eng *engine.Engine, version version.Version, w http.Response
1181 1181
 }
1182 1182
 func writeCorsHeaders(w http.ResponseWriter, r *http.Request) {
1183 1183
 	w.Header().Add("Access-Control-Allow-Origin", "*")
1184
-	w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
1184
+	w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth")
1185 1185
 	w.Header().Add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS")
1186 1186
 }
1187 1187
 
... ...
@@ -785,8 +785,8 @@ func TestGetEnabledCors(t *testing.T) {
785 785
 	if allowOrigin != "*" {
786 786
 		t.Errorf("Expected header Access-Control-Allow-Origin to be \"*\", %s found.", allowOrigin)
787 787
 	}
788
-	if allowHeaders != "Origin, X-Requested-With, Content-Type, Accept" {
789
-		t.Errorf("Expected header Access-Control-Allow-Headers to be \"Origin, X-Requested-With, Content-Type, Accept\", %s found.", allowHeaders)
788
+	if allowHeaders != "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth" {
789
+		t.Errorf("Expected header Access-Control-Allow-Headers to be \"Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth\", %s found.", allowHeaders)
790 790
 	}
791 791
 	if allowMethods != "GET, POST, DELETE, PUT, OPTIONS" {
792 792
 		t.Errorf("Expected hearder Access-Control-Allow-Methods to be \"GET, POST, DELETE, PUT, OPTIONS\", %s found.", allowMethods)