Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 08:30 UTC
intercept: fix misleading handle_response error for extra matcher args (#7871)
Same obsolete two-argument check as the reverse_proxy one removed in #7869: it referenced the long-removed inline status-code-replacement syntax and pointed users at replace_status even when no status replacement was involved. The generic check now rejects all excess-argument cases with an accurate message. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
TowyTowy committed
Jul 12, 2026 at 01:16 UTC
c1907df2edbaa7f7ab8b4f13843bb8ee1a618e4a
2 files changed
+12
-6
caddytest/integration/caddyfile_adapt/intercept_handle_response_too_many_args.caddyfiletest
new
+11
@@ -0,0 +1,11 @@
1
+localhost:8884 {
2
+ intercept {
3
+ handle_response header Foo {
4
+ respond "handled"
5
+ }
6
+ }
7
+ respond "hello"
8
+}
9
+
10
+----------
11
+parsing caddyfile tokens for 'intercept': too many arguments for 'handle_response': only a single response matcher name is allowed, but got: [header Foo]
modules/caddyhttp/intercept/intercept.go
+1
-6
@@ -303,13 +303,8 @@ func (i *Intercept) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) erro
303
d.Next()
304
args := d.RemainingArgs()
305
306
- // TODO: Remove this check at some point in the future
307
- if len(args) == 2 {
308
- return d.Errf("configuring 'handle_response' for status code replacement is no longer supported. Use 'replace_status' instead.")
309
- }
310
-
306
if len(args) > 1 {
312
- return d.Errf("too many arguments for 'handle_response': %s", args)
307
+ return d.Errf("too many arguments for 'handle_response': only a single response matcher name is allowed, but got: %s", args)
308
}
309
310
var matcher *caddyhttp.ResponseMatcher