Skip to content

Commit a29b26b

Browse files
hsanjuanStebalien
authored andcommitted
Fix go-ipfs#7242: Remove "HEAD" from Allow methods
(when GET is not allowed).
1 parent 90c723d commit a29b26b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

http/errors_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func TestUnhandledMethod(t *testing.T) {
165165
AllowGet: false,
166166
Code: http.StatusMethodNotAllowed,
167167
ResHeaders: map[string]string{
168-
"Allow": "POST, HEAD, OPTIONS",
168+
"Allow": "POST, OPTIONS",
169169
},
170170
}
171171
tc.test(t)

http/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
192192
}
193193

194194
func setAllowedHeaders(w http.ResponseWriter, allowGet bool) {
195-
w.Header().Add("Allow", http.MethodHead)
196195
w.Header().Add("Allow", http.MethodOptions)
197196
w.Header().Add("Allow", http.MethodPost)
198197
if allowGet {
198+
w.Header().Add("Allow", http.MethodHead)
199199
w.Header().Add("Allow", http.MethodGet)
200200
}
201201
}

0 commit comments

Comments
 (0)