Commit a29b26be authored by Hector Sanjuan's avatar Hector Sanjuan Committed by Steven Allen

Fix go-ipfs#7242: Remove "HEAD" from Allow methods

(when GET is not allowed).
parent 90c723d6
...@@ -165,7 +165,7 @@ func TestUnhandledMethod(t *testing.T) { ...@@ -165,7 +165,7 @@ func TestUnhandledMethod(t *testing.T) {
AllowGet: false, AllowGet: false,
Code: http.StatusMethodNotAllowed, Code: http.StatusMethodNotAllowed,
ResHeaders: map[string]string{ ResHeaders: map[string]string{
"Allow": "POST, HEAD, OPTIONS", "Allow": "POST, OPTIONS",
}, },
} }
tc.test(t) tc.test(t)
......
...@@ -192,10 +192,10 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -192,10 +192,10 @@ 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.MethodHead)
w.Header().Add("Allow", http.MethodOptions) w.Header().Add("Allow", http.MethodOptions)
w.Header().Add("Allow", http.MethodPost) w.Header().Add("Allow", http.MethodPost)
if allowGet { if allowGet {
w.Header().Add("Allow", http.MethodHead)
w.Header().Add("Allow", http.MethodGet) w.Header().Add("Allow", http.MethodGet)
} }
} }
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