Skip to content

Commit

Permalink
fix: Do not close response body before reading it
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Jun 2, 2024
1 parent 247f4c9 commit bb117c8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/web/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ func DispatchRequest(req *http.Request, output interface{}) (int, error) {
log.Dbg("making request failed: %v", err)
return http.StatusInternalServerError, errors.New("making request failed")
}
if err := res.Body.Close(); err != nil {
log.Dbg("closing request body stream failed: %v", err)
}
defer func() {
if err := res.Body.Close(); err != nil {
log.Dbg("closing request body stream failed: %v", err)
}
}()

if res.StatusCode != http.StatusOK {
msg := readError(req, res)
Expand Down

0 comments on commit bb117c8

Please sign in to comment.