This commit is contained in:
Suryaansh Chawla 2026-06-22 22:43:42 +00:00 committed by GitHub
commit 0cd86018ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -923,9 +923,8 @@ func (h *Handler) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error
d.Next()
args := d.RemainingArgs()
// TODO: Remove this check at some point in the future
if len(args) == 2 {
return d.Errf("configuring 'handle_response' for status code replacement is no longer supported. Use 'replace_status' instead.")
if isStatusReplacementPattern(matcher, subroute) {
return d.Errf("use 'replace_status' instead of 'handle_response' for status changes")
}
if len(args) > 1 {
@ -986,6 +985,12 @@ func (h *Handler) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error
return nil
}
func isStatusReplacementPattern(m caddyhttp.ResponseMatcher) bool {
// If the matcher only checks status codes, and does not
// check headers, it's basically a status-only matcher.
return len(m.StatusCode) > 0 && len(m.Headers) == 0
}
// UnmarshalCaddyfile deserializes Caddyfile tokens into h.
//
// transport http {