Skip to content

Commit

Permalink
webhooks: discarding body after http requests in order to allow reusi…
Browse files Browse the repository at this point in the history
…ng the underlying connection
  • Loading branch information
gosom committed May 9, 2022
1 parent 0e14c9d commit 4fe96f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webhooks.go
Expand Up @@ -5,6 +5,8 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
)

Expand Down Expand Up @@ -51,7 +53,10 @@ func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *h
if err != nil {
return fmt.Errorf("failed to post webhook: %w", err)
}
defer resp.Body.Close()
defer func() {
io.Copy(ioutil.Discard, resp.Body)
resp.Body.Close()
}()

return checkStatusCode(resp, discard{})
}

0 comments on commit 4fe96f9

Please sign in to comment.