From c7ee7c1e2510d518065f938ba8572d4b52d4adde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Wed, 17 Aug 2022 13:21:37 +0200 Subject: [PATCH] Remove superfluous response.WriteHeader call as the Write of the responseWriter automatically sends also the Header. --- internal/api/runners.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/api/runners.go b/internal/api/runners.go index a619c3b..3f5387e 100644 --- a/internal/api/runners.go +++ b/internal/api/runners.go @@ -100,6 +100,7 @@ func (r *RunnerController) fileContent(writer http.ResponseWriter, request *http targetRunner, _ := runner.FromContext(request.Context()) path := request.URL.Query().Get(PathKey) + writer.Header().Set("Content-Type", "application/octet-stream") err := targetRunner.GetFileContent(path, writer, request.Context()) if errors.Is(err, runner.ErrFileNotFound) { writeNotFound(writer, err) @@ -109,9 +110,6 @@ func (r *RunnerController) fileContent(writer http.ResponseWriter, request *http writeInternalServerError(writer, err, dto.ErrorUnknown) return } - - writer.Header().Set("Content-Type", "application/octet-stream") - writer.WriteHeader(http.StatusOK) } // execute handles the execute API route.