diff --git a/http/handler.go b/http/handler.go index 7272b614077cfcf7d900bdfc8a82b1615ad0eb08..349d4d87be97b98548f794f99bd42cdcddf6b00d 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, ", ")) }