summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--caddytest/integration/caddyfile_adapt/header.txt15
-rw-r--r--modules/caddyhttp/headers/caddyfile.go6
2 files changed, 20 insertions, 1 deletions
diff --git a/caddytest/integration/caddyfile_adapt/header.txt b/caddytest/integration/caddyfile_adapt/header.txt
index 95c1474..ec2a842 100644
--- a/caddytest/integration/caddyfile_adapt/header.txt
+++ b/caddytest/integration/caddyfile_adapt/header.txt
@@ -18,6 +18,7 @@
+Link "Bar"
}
header >Set Defer
+ header >Replace Deferred Replacement
}
----------
{
@@ -148,6 +149,20 @@
]
}
}
+ },
+ {
+ "handler": "headers",
+ "response": {
+ "deferred": true,
+ "replace": {
+ "Replace": [
+ {
+ "replace": "Replacement",
+ "search_regexp": "Deferred"
+ }
+ ]
+ }
+ }
}
]
}
diff --git a/modules/caddyhttp/headers/caddyfile.go b/modules/caddyhttp/headers/caddyfile.go
index d7e644c..2b06910 100644
--- a/modules/caddyhttp/headers/caddyfile.go
+++ b/modules/caddyhttp/headers/caddyfile.go
@@ -247,10 +247,14 @@ func applyHeaderOp(ops *HeaderOps, respHeaderOps *RespHeaderOps, field, value, r
respHeaderOps.Set.Set(field, value)
case replacement != "": // replace
+ // allow defer shortcut for replace syntax
+ if strings.HasPrefix(field, ">") && respHeaderOps != nil {
+ respHeaderOps.Deferred = true
+ }
if ops.Replace == nil {
ops.Replace = make(map[string][]Replacement)
}
- field = strings.TrimLeft(field, "+-?")
+ field = strings.TrimLeft(field, "+-?>")
ops.Replace[field] = append(
ops.Replace[field],
Replacement{