Skip to content

Commit

Permalink
Merge pull request #515 from sgotti/v0.9.x_api_add_missing_content_type
Browse files Browse the repository at this point in the history
api: add some missing http content types headers.
  • Loading branch information
sgotti authored May 15, 2024
2 parents 7091839 + 1699400 commit bc0d835
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/services/gateway/api/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ func (h *LogsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// header also if there're currently no lines to send
w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Connection", "keep-alive")
w.Header().Set("Content-Type", "text/plain;charset=UTF-8")
w.WriteHeader(http.StatusOK)
var flusher http.Flusher
if fl, ok := w.(http.Flusher); ok {
Expand Down
1 change: 1 addition & 0 deletions internal/services/runservice/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func (h *LogsHandler) readTaskLogs(ctx context.Context, runID, taskID string, se
// header also if there're currently no lines to send
w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Connection", "keep-alive")
w.Header().Set("Content-Type", "text/plain;charset=UTF-8")
w.WriteHeader(http.StatusOK)
var flusher http.Flusher
if fl, ok := w.(http.Flusher); ok {
Expand Down
2 changes: 2 additions & 0 deletions internal/util/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func HTTPError(w http.ResponseWriter, err error) bool {
return false
}

w.Header().Set("Content-Type", "application/json")

response := ErrorResponseFromError(err)
resj, merr := json.Marshal(response)
if merr != nil {
Expand Down

0 comments on commit bc0d835

Please sign in to comment.