Skip to content

Commit f36ceb1

Browse files
ibnesayeedStebalien
authored andcommitted
Combine Allow headers in a single comma separated list
1 parent a29b26b commit f36ceb1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

http/handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"net/http"
77
"runtime/debug"
8+
"strings"
89
"sync"
910
"time"
1011

@@ -192,10 +193,9 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
192193
}
193194

194195
func setAllowedHeaders(w http.ResponseWriter, allowGet bool) {
195-
w.Header().Add("Allow", http.MethodOptions)
196-
w.Header().Add("Allow", http.MethodPost)
196+
allowedMethods := []string{http.MethodOptions, http.MethodPost}
197197
if allowGet {
198-
w.Header().Add("Allow", http.MethodHead)
199-
w.Header().Add("Allow", http.MethodGet)
198+
allowedMethods = append(allowedMethods, http.MethodHead, http.MethodGet)
200199
}
200+
w.Header().Set("Allow", strings.Join(allowedMethods, ", "))
201201
}

0 commit comments

Comments
 (0)