Skip to content

Commit

Permalink
bug fix:SlimApiInvoker 未正确关闭 http.Response.Body 。
Browse files Browse the repository at this point in the history
  • Loading branch information
cmstar committed Jul 5, 2023
1 parent ab01ed7 commit b1c3df8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions slimapi/slimapi_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ func (x SlimApiInvoker[TParam, TData]) DoRaw(params TParam) (res webapi.ApiRespo
return
}

defer func() {
e := response.Body.Close()
if err == nil {
err = e
}
// Drop e if err is not nil.
}()

out, err := io.ReadAll(response.Body)
if err != nil {
err = wrapErr(err)
Expand Down

0 comments on commit b1c3df8

Please sign in to comment.