Skip to content

Commit

Permalink
fix: http response body not close on status >= 400 (close #5163)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 5, 2023
1 parent 6f6d20e commit f2f312b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/net/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ func RequestHttp(ctx context.Context, httpMethod string, headerOverride http.Hea
res.Header.Del("set-cookie")
if res.StatusCode >= 400 {
all, _ := io.ReadAll(res.Body)
_ = res.Body.Close()
msg := string(all)
log.Debugln(msg)
return res, errors.New(msg)
return nil, fmt.Errorf("http request [%s] failure,status: %d response:%s", URL, res.StatusCode, msg)
}
return res, nil
}
Expand Down

0 comments on commit f2f312b

Please sign in to comment.