From f36ceb1e124e556b481a6295698d917ae1a15824 Mon Sep 17 00:00:00 2001 From: Sawood Alam Date: Wed, 29 Apr 2020 13:01:52 -0400 Subject: [PATCH] Combine Allow headers in a single comma separated list --- http/handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http/handler.go b/http/handler.go index 7272b61..349d4d8 100644 --- a/http/handler.go +++ b/http/handler.go @@ -5,6 +5,7 @@ import ( "errors" "net/http" "runtime/debug" + "strings" "sync" "time" @@ -192,10 +193,9 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func setAllowedHeaders(w http.ResponseWriter, allowGet bool) { - w.Header().Add("Allow", http.MethodOptions) - w.Header().Add("Allow", http.MethodPost) + allowedMethods := []string{http.MethodOptions, http.MethodPost} if allowGet { - w.Header().Add("Allow", http.MethodHead) - w.Header().Add("Allow", http.MethodGet) + allowedMethods = append(allowedMethods, http.MethodHead, http.MethodGet) } + w.Header().Set("Allow", strings.Join(allowedMethods, ", ")) } -- GitLab