Merge pull request #3402 from manuel-woelker/3345-add-content-type-header-to-version-remote-api

Fix for #3345: Add Content-Type Header "application/json" to GET /version response in remote API
This commit is contained in:
Victor Vieux 2014-01-08 10:15:22 -08:00
commit 149156a272
2 changed files with 10 additions and 0 deletions

2
api.go
View File

@ -140,6 +140,7 @@ func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reque
}
func getVersion(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
w.Header().Set("Content-Type", "application/json")
srv.Eng.ServeHTTP(w, r)
return nil
}
@ -216,6 +217,7 @@ func getImagesViz(srv *Server, version float64, w http.ResponseWriter, r *http.R
}
func getInfo(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
w.Header().Set("Content-Type", "application/json")
srv.Eng.ServeHTTP(w, r)
return nil
}

View File

@ -49,6 +49,10 @@ func TestGetVersion(t *testing.T) {
if result := v.Get("Version"); result != expected {
t.Errorf("Expected version %s, %s found", expected, result)
}
expected = "application/json"
if result := r.HeaderMap.Get("Content-Type"); result != expected {
t.Errorf("Expected Content-Type %s, %s found", expected, result)
}
}
func TestGetInfo(t *testing.T) {
@ -84,6 +88,10 @@ func TestGetInfo(t *testing.T) {
if images := i.GetInt("Images"); images != len(initialImages) {
t.Errorf("Expected images: %d, %d found", len(initialImages), images)
}
expected := "application/json"
if result := r.HeaderMap.Get("Content-Type"); result != expected {
t.Errorf("Expected Content-Type %s, %s found", expected, result)
}
}
func TestGetEvents(t *testing.T) {