caddyhttp: Allow header
replacement with empty string
#6163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: https://caddy.community/t/caddy-ntlm-reverse-proxy-constant-401-with-windows-admin-center/22900/5
Turns out that the Caddyfile adapter was using
""
for the replacement value as meaning "this isn't a replacement, make it aset
operation instead". That's unfortunate, because in the Caddyfile, using""
as an empty string for the 2nd token can be done intentionally. Using replacement as empty string to detect if it wasn't set isn't ideal.So the solution I came up with is to make it a
*string
instead to allow it to be nil instead as the default for no argument being passed.It does mean we're modifying the signature of an exported function, but I don't think it has any plugin impact: https://sourcegraph.com/search?q=context:global+CaddyfileHeaderOp+-file:vendor/github.com/caddyserver&patternType=keyword&sm=0 (this search excludes Caddy in
vendor/
directories which is the bulk of the results that aren't Caddy itself).