mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
federation/client: Add option to not close response body in MakeFullRequest
This commit is contained in:
parent
cfa47299df
commit
c343399568
1 changed files with 8 additions and 5 deletions
|
|
@ -283,8 +283,9 @@ type RequestParams struct {
|
|||
Authenticate bool
|
||||
RequestJSON any
|
||||
|
||||
ResponseJSON any
|
||||
DontReadBody bool
|
||||
ResponseJSON any
|
||||
DontReadBody bool
|
||||
DontCloseBody bool
|
||||
}
|
||||
|
||||
func (c *Client) MakeRequest(ctx context.Context, serverName string, authenticate bool, method string, path mautrix.PrefixableURLPath, reqJSON, respJSON any) error {
|
||||
|
|
@ -314,9 +315,11 @@ func (c *Client) MakeFullRequest(ctx context.Context, params RequestParams) ([]b
|
|||
WrappedError: err,
|
||||
}
|
||||
}
|
||||
defer func() {
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
if !params.DontCloseBody {
|
||||
defer func() {
|
||||
_ = 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