From 443af8059ea9148a38effca11c4808153fc0e24b Mon Sep 17 00:00:00 2001 From: Sam Lin Date: Thu, 5 Jan 2023 10:37:42 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feature:=20Forward=20all=20known=20Git?= =?UTF-8?q?Hub=20headers=20#105?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/parser/parser.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 3db2201..e4b3806 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -14,11 +14,17 @@ func Parse(req *http.Request, provider providers.Provider) (*providers.Hook, err } for _, header := range provider.GetHeaderKeys() { - if req.Header.Get(header) != "" { - hook.Headers[header] = req.Header.Get(header) - continue + if req.Header.Get(header) == "" { + return nil, errors.New("Required header '" + header + "' not found in Request") } - return nil, errors.New("Required header '" + header + "' not found in Request") + + // Store required headers in the expected casing + hook.Headers[header] = req.Header.Get(header) + } + + for header := range req.Header { + // Store the rest of the headers in any casing + hook.Headers[header] = req.Header.Get(header) } if body, err := ioutil.ReadAll(req.Body); err != nil {