Skip to content

Commit

Permalink
dont try to json parse arbitrary http error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
mpfz0r committed Oct 13, 2023
1 parent 1054cfd commit 2b720be
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions api/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,9 @@ func CheckResponse(r *http.Response) error {
}

errorResponse := &ErrorResponse{Response: r}
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(io.LimitReader(r.Body, 2048))
if err == nil && len(data) > 0 {
err := json.Unmarshal(data, errorResponse)
if err != nil {
return err
}
errorResponse.Message = string(data)
}

return errorResponse
Expand Down

0 comments on commit 2b720be

Please sign in to comment.