mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-13 22:36:27 +03:00
headers: Allow >
to defer shortcut for replacements (#5574)
This commit is contained in:
parent
6a41b62e70
commit
3b19aa2b5a
2 changed files with 20 additions and 1 deletions
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in a new issue