Browse code

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

Signed-off-by: Vladimir Bulyga <xx@ccxx.cc>

Vladimir Bulyga authored on 2014/11/02 01:22:28
Showing 2 changed files
... ...
@@ -1167,7 +1167,7 @@ func optionsHandler(eng *engine.Engine, version version.Version, w http.Response
1167 1167
 }
1168 1168
 func writeCorsHeaders(w http.ResponseWriter, r *http.Request) {
1169 1169
 	w.Header().Add("Access-Control-Allow-Origin", "*")
1170
-	w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
1170
+	w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth")
1171 1171
 	w.Header().Add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS")
1172 1172
 }
1173 1173
 
... ...
@@ -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)