diff --git a/api/buildserver/create.go b/api/buildserver/create.go index 693c937b3..6e8a40e35 100644 --- a/api/buildserver/create.go +++ b/api/buildserver/create.go @@ -38,6 +38,7 @@ func (s *Server) CreateBuild(team db.Team) http.Handler { go engineBuild.Resume(hLog) + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) err = json.NewEncoder(w).Encode(present.Build(build)) diff --git a/api/buildserver/get.go b/api/buildserver/get.go index 99b781fa9..427c8498b 100644 --- a/api/buildserver/get.go +++ b/api/buildserver/get.go @@ -12,6 +12,7 @@ func (s *Server) GetBuild(build db.Build) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { logger := s.logger.Session("get-build") + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err := json.NewEncoder(w).Encode(present.Build(build)) diff --git a/api/buildserver/plan.go b/api/buildserver/plan.go index 78ee2d8ef..1a2c13bdd 100644 --- a/api/buildserver/plan.go +++ b/api/buildserver/plan.go @@ -12,6 +12,7 @@ func (s *Server) GetBuildPlan(build db.Build) http.Handler { hLog := s.logger.Session("get-build-plan") return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(atc.PublicBuildPlan{ Schema: build.Engine(), Plan: build.PublicPlan(), diff --git a/api/buildserver/preparation.go b/api/buildserver/preparation.go index 483dc7d17..f3b9fc153 100644 --- a/api/buildserver/preparation.go +++ b/api/buildserver/preparation.go @@ -25,6 +25,7 @@ func (s *Server) GetBuildPreparation(build db.Build) http.Handler { return } + w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(present.BuildPreparation(prep)) if err != nil { logger.Error("failed-to-encode-build-preparation", err) diff --git a/api/buildserver/resources.go b/api/buildserver/resources.go index c2402e57d..aa9924390 100644 --- a/api/buildserver/resources.go +++ b/api/buildserver/resources.go @@ -36,6 +36,7 @@ func (s *Server) BuildResources(build db.Build) http.Handler { Outputs: atcOutputs, } + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err = json.NewEncoder(w).Encode(output) if err != nil { diff --git a/api/configserver/get.go b/api/configserver/get.go index 273003c75..d1dba29c6 100644 --- a/api/configserver/get.go +++ b/api/configserver/get.go @@ -78,6 +78,7 @@ func (s *Server) GetConfig(w http.ResponseWriter, r *http.Request) { } w.Header().Set(atc.ConfigVersionHeader, fmt.Sprintf("%d", pipeline.ConfigVersion())) + w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(atc.ConfigResponse{ Config: &config, diff --git a/api/configserver/save.go b/api/configserver/save.go index bc2c75470..7d305246e 100644 --- a/api/configserver/save.go +++ b/api/configserver/save.go @@ -134,6 +134,8 @@ func (s *Server) SaveConfig(w http.ResponseWriter, r *http.Request) { session.Info("saved") + w.Header().Set("Content-Type", "application/json") + if created { w.WriteHeader(http.StatusCreated) } else { diff --git a/api/infoserver/info.go b/api/infoserver/info.go index 52680e63f..55e876bc5 100644 --- a/api/infoserver/info.go +++ b/api/infoserver/info.go @@ -10,6 +10,7 @@ import ( func (s *Server) Info(w http.ResponseWriter, r *http.Request) { logger := s.logger.Session("info") + w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(atc.Info{Version: s.version, WorkerVersion: s.workerVersion}) if err != nil { logger.Error("failed-to-encode-info", err) diff --git a/api/jobserver/get.go b/api/jobserver/get.go index 5b35b7513..0494fcb73 100644 --- a/api/jobserver/get.go +++ b/api/jobserver/get.go @@ -34,6 +34,7 @@ func (s *Server) GetJob(pipeline db.Pipeline) http.Handler { teamName := r.FormValue(":team_name") + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err = json.NewEncoder(w).Encode(present.Job( diff --git a/api/jobserver/get_build.go b/api/jobserver/get_build.go index b6349bc27..1e05c61f0 100644 --- a/api/jobserver/get_build.go +++ b/api/jobserver/get_build.go @@ -38,6 +38,7 @@ func (s *Server) GetJobBuild(pipeline db.Pipeline) http.Handler { return } + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err = json.NewEncoder(w).Encode(present.Build(build)) diff --git a/api/jobserver/list_inputs.go b/api/jobserver/list_inputs.go index 94fac9247..97125e4a6 100644 --- a/api/jobserver/list_inputs.go +++ b/api/jobserver/list_inputs.go @@ -71,6 +71,7 @@ func (s *Server) ListJobInputs(pipeline db.Pipeline) http.Handler { presentedBuildInputs[i] = present.BuildInput(input, config, resource.Source()) } + w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(presentedBuildInputs) if err != nil { logger.Error("failed-to-encode-build-inputs", err) diff --git a/api/pipelineserver/build.go b/api/pipelineserver/build.go index f89edc25a..3fc4cdb67 100644 --- a/api/pipelineserver/build.go +++ b/api/pipelineserver/build.go @@ -38,6 +38,7 @@ func (s *Server) CreateBuild(pipelineDB db.Pipeline) http.Handler { go engineBuild.Resume(logger) + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) err = json.NewEncoder(w).Encode(present.Build(build)) diff --git a/api/resourceserver/get.go b/api/resourceserver/get.go index 23e4e5514..029a21466 100644 --- a/api/resourceserver/get.go +++ b/api/resourceserver/get.go @@ -36,6 +36,7 @@ func (s *Server) GetResource(pipeline db.Pipeline) http.Handler { teamName, ) + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err = json.NewEncoder(w).Encode(resource) diff --git a/api/resourceserver/list.go b/api/resourceserver/list.go index 9cd36e9fa..790c48d25 100644 --- a/api/resourceserver/list.go +++ b/api/resourceserver/list.go @@ -37,6 +37,7 @@ func (s *Server) ListResources(pipeline db.Pipeline) http.Handler { ) } + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err = json.NewEncoder(w).Encode(presentedResources) if err != nil { diff --git a/api/teamserver/list.go b/api/teamserver/list.go index 284bc9765..929e3535c 100644 --- a/api/teamserver/list.go +++ b/api/teamserver/list.go @@ -23,6 +23,7 @@ func (s *Server) ListTeams(w http.ResponseWriter, r *http.Request) { presentedTeams[i] = present.Team(team) } + w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(presentedTeams) if err != nil { hLog.Error("failed-to-encode-teams", err) diff --git a/api/teamserver/set.go b/api/teamserver/set.go index f879af565..67de15855 100644 --- a/api/teamserver/set.go +++ b/api/teamserver/set.go @@ -91,6 +91,7 @@ func (s *Server) SetTeam(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) } else if acc.IsAdmin() { hLog.Debug("creating team") @@ -101,6 +102,7 @@ func (s *Server) SetTeam(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) return } + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) } else { w.WriteHeader(http.StatusForbidden) diff --git a/api/volumeserver/list.go b/api/volumeserver/list.go index c45975612..441b52355 100644 --- a/api/volumeserver/list.go +++ b/api/volumeserver/list.go @@ -35,6 +35,7 @@ func (s *Server) ListVolumes(team db.Team) http.Handler { } } + w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(presentedVolumes) if err != nil { hLog.Error("failed-to-encode-volumes", err) diff --git a/api/workerserver/heartbeat.go b/api/workerserver/heartbeat.go index d70529c6a..bac1c76ad 100644 --- a/api/workerserver/heartbeat.go +++ b/api/workerserver/heartbeat.go @@ -64,6 +64,7 @@ func (s *Server) HeartbeatWorker(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) err = json.NewEncoder(w).Encode(present.Worker(savedWorker)) if err != nil { diff --git a/api/workerserver/list.go b/api/workerserver/list.go index 20290beba..88af68f5d 100644 --- a/api/workerserver/list.go +++ b/api/workerserver/list.go @@ -29,6 +29,7 @@ func (s *Server) ListWorkers(w http.ResponseWriter, r *http.Request) { atcWorkers[i] = present.Worker(savedWorker) } + w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(atcWorkers) if err != nil { logger.Error("failed-to-encode-workers", err)