Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caddyhttp: Allow header replacement with empty string #6163

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

francislavoie
Copy link
Member

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 a set 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).

@francislavoie francislavoie added the bug 🐞 Something isn't working label Mar 9, 2024
@francislavoie francislavoie added this to the v2.8.0 milestone Mar 9, 2024
@francislavoie francislavoie requested a review from mholt March 9, 2024 01:31
@mholt
Copy link
Member

mholt commented Mar 13, 2024

Thanks for the patch. Makes sense. But was it intentional to change the output JSON?

@francislavoie
Copy link
Member Author

Oh oops, I thought I ran the tests before committing. My bad, I'll revise

@francislavoie francislavoie force-pushed the empty-string-header-replacement branch from dd03cde to 09f3aa5 Compare March 16, 2024 17:48
@francislavoie
Copy link
Member Author

Ok @mholt it's good to go now.

@francislavoie francislavoie force-pushed the empty-string-header-replacement branch from 09f3aa5 to 9457383 Compare March 16, 2024 18:18
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM!

@mholt mholt enabled auto-merge (squash) March 21, 2024 17:22
@mholt mholt merged commit 97a56d8 into master Mar 21, 2024
25 checks passed
@mholt mholt deleted the empty-string-header-replacement branch March 21, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants