Commit f36ceb1e authored by Sawood Alam's avatar Sawood Alam Committed by Steven Allen

Combine Allow headers in a single comma separated list

parent a29b26be
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"errors" "errors"
"net/http" "net/http"
"runtime/debug" "runtime/debug"
"strings"
"sync" "sync"
"time" "time"
...@@ -192,10 +193,9 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -192,10 +193,9 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
func setAllowedHeaders(w http.ResponseWriter, allowGet bool) { func setAllowedHeaders(w http.ResponseWriter, allowGet bool) {
w.Header().Add("Allow", http.MethodOptions) allowedMethods := []string{http.MethodOptions, http.MethodPost}
w.Header().Add("Allow", http.MethodPost)
if allowGet { if allowGet {
w.Header().Add("Allow", http.MethodHead) allowedMethods = append(allowedMethods, http.MethodHead, http.MethodGet)
w.Header().Add("Allow", http.MethodGet)
} }
w.Header().Set("Allow", strings.Join(allowedMethods, ", "))
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment