From 57b95ec88ec08a1af74c9b019651b50634cf4677 Mon Sep 17 00:00:00 2001 From: Suryaansh Chawla Date: Mon, 11 May 2026 20:21:15 +0530 Subject: [PATCH] fix --- modules/caddyhttp/reverseproxy/caddyfile.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go index 8716babe3..55bd6a0d3 100644 --- a/modules/caddyhttp/reverseproxy/caddyfile.go +++ b/modules/caddyhttp/reverseproxy/caddyfile.go @@ -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 {