Browse code

Add explicit status response to OPTIONS handler

Write the http.StatusOK header in the OPTIONS
handler and update the unit tests to refer to the
response code using the const from the http package.

Michael Crosby authored on 2013/06/11 08:44:10
Showing 2 changed files
... ...
@@ -793,6 +793,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
793 793
 		if srv.enableCors {
794 794
 			writeCorsHeaders(w, r)
795 795
 		}
796
+		w.WriteHeader(http.StatusOK)
796 797
 	})
797 798
 	return r, nil
798 799
 }
... ...
@@ -1260,7 +1260,7 @@ func TestOptionsRoute(t *testing.T) {
1260 1260
 	}
1261 1261
 
1262 1262
 	router.ServeHTTP(r, req)
1263
-	if r.Code != 200 {
1263
+	if r.Code != http.StatusOK {
1264 1264
 		t.Errorf("Expected response for OPTIONS request to be \"200\", %v found.", r.Code)
1265 1265
 	}
1266 1266
 }
... ...
@@ -1287,7 +1287,7 @@ func TestGetEnabledCors(t *testing.T) {
1287 1287
 	}
1288 1288
 
1289 1289
 	router.ServeHTTP(r, req)
1290
-	if r.Code != 200 {
1290
+	if r.Code != http.StatusOK {
1291 1291
 		t.Errorf("Expected response for OPTIONS request to be \"200\", %v found.", r.Code)
1292 1292
 	}
1293 1293