Skip to content

Commit

Permalink
Fix response in case of resumable upload (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 committed Feb 29, 2024
1 parent e1e08bc commit 6b610aa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions server/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ func (p *Plugin) httpResponseHandler(res *httpResponse, w http.ResponseWriter) {
if res.Code != 0 {
w.WriteHeader(res.Code)
}
w.Header().Add("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(res); err != nil {
p.LogError(fmt.Sprintf("failed to encode data: %s", err))
if res.Code != http.StatusNoContent {
w.Header().Add("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(res); err != nil {
p.LogError(fmt.Sprintf("failed to encode data: %s", err))
}
}
}
}
Expand All @@ -42,7 +44,7 @@ func (p *Plugin) httpAudit(handler string, res *httpResponse, w http.ResponseWri
if res.Err != "" {
logFields = append(logFields, "error", res.Err, "code", res.Code, "status", "fail")
} else {
logFields = append(logFields, "status", "success")
logFields = append(logFields, "code", res.Code, "status", "success")
}

p.httpResponseHandler(res, w)
Expand Down

0 comments on commit 6b610aa

Please sign in to comment.