fix(header): Allow header according to RFC 7231 (HTTP 405) (#3759)

Co-authored-by: Helios <i@shangyes.net>
This commit is contained in:
Gabriel Augendre
2024-02-06 04:08:56 +01:00
committed by GitHub
parent e957d1abf1
commit 86ff4a64c7
2 changed files with 23 additions and 3 deletions
+12
View File
@@ -514,6 +514,18 @@ func TestRouteNotAllowedEnabled2(t *testing.T) {
assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
}
func TestRouteNotAllowedEnabled3(t *testing.T) {
router := New()
router.HandleMethodNotAllowed = true
router.GET("/path", func(c *Context) {})
router.POST("/path", func(c *Context) {})
w := PerformRequest(router, http.MethodPut, "/path")
assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
allowed := w.Header().Get("Allow")
assert.Contains(t, allowed, "GET")
assert.Contains(t, allowed, "POST")
}
func TestRouteNotAllowedDisabled(t *testing.T) {
router := New()
router.HandleMethodNotAllowed = false