You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
headers: JSON strings deleted when setting response headers #4418
It's being interpreted as a placeholder - escaping the first { (i.e. \{) makes this work. Still - is that expected behaviour? I’d expect either the string to be interpreted literally if it can’t resolve the placeholder, or some kind of error logged to tell me that the placeholder is invalid
Yeah, so this is kind of intentional, because you can escape curly braces it makes it possible to have the flexibility of placeholders that don't always have values without rendering a raw literal placeholder, while also using curly braces by means of escaping. (See #4419 (review).)
I'm open to changing this behavior so that escaping is not necessary, but I believe you'll lose the ability to use placeholders that aren't always set.
Activity
hairyhenderson commentedon Nov 14, 2021
It's also worth noting that this isn't a
Caddyfile-specific bug - the equivalent JSON config also fails:{ "apps": { "http": { "servers": { "srv0": { "listen": [ ":443" ], "routes": [ { "match": [ { "host": [ "localhost" ] } ], "handle": [ { "handler": "subroute", "routes": [ { "handle": [ { "handler": "headers", "response": { "set": { "Foo": [ "{\"foo\":\"bar\"}" ] } } }, { "body": "hello world", "handler": "static_response" } ] } ] } ], "terminal": true } ] } } } } }hairyhenderson commentedon Nov 14, 2021
It's being interpreted as a placeholder - escaping the first
{(i.e.\{) makes this work. Still - is that expected behaviour? I’d expect either the string to be interpreted literally if it can’t resolve the placeholder, or some kind of error logged to tell me that the placeholder is invalidmholt commentedon Nov 15, 2021
Yeah, so this is kind of intentional, because you can escape curly braces it makes it possible to have the flexibility of placeholders that don't always have values without rendering a raw literal placeholder, while also using curly braces by means of escaping. (See #4419 (review).)
I'm open to changing this behavior so that escaping is not necessary, but I believe you'll lose the ability to use placeholders that aren't always set.
francislavoie commentedon Dec 3, 2021
Since you closed the PR, I guess we can close the issue as well.
hairyhenderson commentedon Dec 3, 2021
thanks @francislavoie - I meant to do this but totally missed it 😅
caddyhttp: only replace known placeholders in respond headers (#8014)