Skip to content

Commit

Permalink
Merge pull request #1061 from gosom/master
Browse files Browse the repository at this point in the history
webhooks: discarding body after http requests in order to allow reusi…
  • Loading branch information
kanata2 committed May 19, 2022
2 parents 3cd1edc + 4fe96f9 commit 34c7fd3
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 34c7fd3

Please sign in to comment.