mirror of
https://github.com/caddyserver/caddy.git
synced 2026-11-20 23:09:46 +00:00
admin: set Allow header on /info 405 response
Per RFC 9110 §15.5.6, a 405 response must include an Allow header listing the supported methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
177f7244a0
commit
5cc146a7b1
2 changed files with 4 additions and 0 deletions
|
|
@ -57,6 +57,7 @@ type infoResponse struct {
|
|||
|
||||
func (AdminInfo) handleInfo(w http.ResponseWriter, r *http.Request) error {
|
||||
if r.Method != http.MethodGet {
|
||||
w.Header().Set("Allow", http.MethodGet)
|
||||
return APIError{
|
||||
HTTPStatus: http.StatusMethodNotAllowed,
|
||||
Message: "method not allowed",
|
||||
|
|
|
|||
|
|
@ -90,5 +90,8 @@ func TestAdminInfoHandler(t *testing.T) {
|
|||
if apiErr.HTTPStatus != http.StatusMethodNotAllowed {
|
||||
t.Errorf("expected status %d, got %d", http.StatusMethodNotAllowed, apiErr.HTTPStatus)
|
||||
}
|
||||
if allow := rec.Header().Get("Allow"); allow != http.MethodGet {
|
||||
t.Errorf("expected Allow header %q, got %q", http.MethodGet, allow)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue