diff --git a/internal/matrix/events.go b/internal/matrix/events.go index 818ac5f..0489ea8 100644 --- a/internal/matrix/events.go +++ b/internal/matrix/events.go @@ -82,6 +82,7 @@ func (p *processor) acceptInvite(e *RawEvent) error { if err != nil { return fmt.Errorf("http error accepting invitation: %v", err) } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return p.handleErrorResponse(e, resp) } @@ -106,6 +107,7 @@ func (p *processor) handleVerb(e *RawEvent, cmd, arg string) error { if err != nil { return fmt.Errorf("http error sending message: %v", err) } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return p.handleErrorResponse(e, resp) } @@ -114,7 +116,6 @@ func (p *processor) handleVerb(e *RawEvent, cmd, arg string) error { } func (p *processor) handleErrorResponse(e *RawEvent, resp *http.Response) error { - defer resp.Body.Close() var er errorResponse if err := json.NewDecoder(resp.Body).Decode(&er); err != nil { return fmt.Errorf("could not decode response: %v", err)