From c66aa70f0749662beadc24320a7a11e5be736b4a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 29 Sep 2020 03:57:49 -0600 Subject: [PATCH] bugfix ignored MaxBytesReader --- internal/webhooks/bitbucket/bitbucket.go | 5 +---- internal/webhooks/github/github.go | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/webhooks/bitbucket/bitbucket.go b/internal/webhooks/bitbucket/bitbucket.go index d865798..2a3c7a7 100644 --- a/internal/webhooks/bitbucket/bitbucket.go +++ b/internal/webhooks/bitbucket/bitbucket.go @@ -43,10 +43,7 @@ func InitWebhook(providername string, secret *string, envname string) func() { secretB := []byte(*secret) webhooks.AddRouteHandler(providername, func(router chi.Router) { router.Post("/", func(w http.ResponseWriter, r *http.Request) { - body := http.MaxBytesReader(w, r.Body, options.DefaultMaxBodySize) - defer func() { - _ = body.Close() - }() + r.Body = http.MaxBytesReader(w, r.Body, options.DefaultMaxBodySize) accessToken := r.URL.Query().Get("access_token") if "" != accessToken { diff --git a/internal/webhooks/github/github.go b/internal/webhooks/github/github.go index ddac5ca..4704950 100644 --- a/internal/webhooks/github/github.go +++ b/internal/webhooks/github/github.go @@ -38,10 +38,7 @@ func InitWebhook(providername string, secret *string, envname string) func() { githubSecretB := []byte(*secret) webhooks.AddRouteHandler(providername, func(router chi.Router) { router.Post("/", func(w http.ResponseWriter, r *http.Request) { - body := http.MaxBytesReader(w, r.Body, options.DefaultMaxBodySize) - defer func() { - _ = body.Close() - }() + r.Body = http.MaxBytesReader(w, r.Body, options.DefaultMaxBodySize) payload, err := ioutil.ReadAll(r.Body) if err != nil {