mirror of
https://github.com/caddyserver/caddy.git
synced 2025-08-11 09:16:26 -04:00
* fix: resolve http.request placeholders in header directive find operation - Skip regex compilation during provision when placeholders are detected - Compile regex at runtime after placeholder replacement - Preserves performance for static regexes while enabling dynamic placeholders - Fixes #7109 * test: add tests for placeholder detection in header replacements - Test containsPlaceholders function edge cases - Test provision skips compilation for dynamic regexes - Test end-to-end placeholder replacement functionality
64 lines
1.2 KiB
Plaintext
64 lines
1.2 KiB
Plaintext
:80 {
|
|
header Test-Static ":443" "STATIC-WORKS"
|
|
header Test-Dynamic ":{http.request.local.port}" "DYNAMIC-WORKS"
|
|
header Test-Complex "port-{http.request.local.port}-end" "COMPLEX-{http.request.method}"
|
|
}
|
|
----------
|
|
{
|
|
"apps": {
|
|
"http": {
|
|
"servers": {
|
|
"srv0": {
|
|
"listen": [
|
|
":80"
|
|
],
|
|
"routes": [
|
|
{
|
|
"handle": [
|
|
{
|
|
"handler": "headers",
|
|
"response": {
|
|
"replace": {
|
|
"Test-Static": [
|
|
{
|
|
"replace": "STATIC-WORKS",
|
|
"search_regexp": ":443"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"handler": "headers",
|
|
"response": {
|
|
"replace": {
|
|
"Test-Dynamic": [
|
|
{
|
|
"replace": "DYNAMIC-WORKS",
|
|
"search_regexp": ":{http.request.local.port}"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"handler": "headers",
|
|
"response": {
|
|
"replace": {
|
|
"Test-Complex": [
|
|
{
|
|
"replace": "COMPLEX-{http.request.method}",
|
|
"search_regexp": "port-{http.request.local.port}-end"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |