From 3b561a468232c18c63d98920ce2812721d853f29 Mon Sep 17 00:00:00 2001 From: Aditya R Date: Mon, 7 Feb 2022 13:38:16 +0530 Subject: compat: endpoint /build must set header content type as application/json in reponse Lot of clients are expecting proper `Content-type: application/json` configured in response headers of `/build` compat api. Following commit fixes that. Fixes issues where code is setting header field after writing header which is wrong. We must set `content-type` before we write and flush http header. Signed-off-by: Aditya R --- pkg/api/handlers/compat/images_build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/api/handlers/compat') diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index cc9667202..0ebf74f98 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -605,8 +605,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } // Send headers and prime client for stream to come - w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) flush() body := w.(io.Writer) -- cgit v1.2.3-54-g00ecf