mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 22:35:52 +01:00
parent
cfa47299df
commit
36d4e1f99c
2 changed files with 4 additions and 3 deletions
|
|
@ -707,6 +707,7 @@ const ErrorResponseSizeLimit = 512 * 1024
|
|||
var DefaultResponseSizeLimit int64 = 512 * 1024 * 1024
|
||||
|
||||
func ParseErrorResponse(req *http.Request, res *http.Response) ([]byte, error) {
|
||||
defer res.Body.Close()
|
||||
contents, err := readResponseBody(req, res, ErrorResponseSizeLimit)
|
||||
if err != nil {
|
||||
return contents, err
|
||||
|
|
|
|||
|
|
@ -314,9 +314,9 @@ func (c *Client) MakeFullRequest(ctx context.Context, params RequestParams) ([]b
|
|||
WrappedError: err,
|
||||
}
|
||||
}
|
||||
defer func() {
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
if !params.DontReadBody {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
var body []byte
|
||||
if resp.StatusCode >= 300 {
|
||||
body, err = mautrix.ParseErrorResponse(req, resp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue