From a29b26bef9b0110777d68240f0d7a8514f7552c9 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 29 Apr 2020 00:09:47 +0200 Subject: [PATCH] Fix go-ipfs#7242: Remove "HEAD" from Allow methods (when GET is not allowed). --- http/errors_test.go | 2 +- http/handler.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/http/errors_test.go b/http/errors_test.go index 48b8359..bb5b684 100644 --- a/http/errors_test.go +++ b/http/errors_test.go @@ -165,7 +165,7 @@ func TestUnhandledMethod(t *testing.T) { AllowGet: false, Code: http.StatusMethodNotAllowed, ResHeaders: map[string]string{ - "Allow": "POST, HEAD, OPTIONS", + "Allow": "POST, OPTIONS", }, } tc.test(t) diff --git a/http/handler.go b/http/handler.go index a1756f6..7272b61 100644 --- a/http/handler.go +++ b/http/handler.go @@ -192,10 +192,10 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func setAllowedHeaders(w http.ResponseWriter, allowGet bool) { - w.Header().Add("Allow", http.MethodHead) w.Header().Add("Allow", http.MethodOptions) w.Header().Add("Allow", http.MethodPost) if allowGet { + w.Header().Add("Allow", http.MethodHead) w.Header().Add("Allow", http.MethodGet) } } -- GitLab