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

docs: document more of header directive behavior #442

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lilnasy
Copy link

@lilnasy lilnasy commented Jan 8, 2025

header <field> [<value>]
header <field> <value>
Copy link
Author

Choose a reason for hiding this comment

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

I might be reading this wrong, but this seemed to suggest that the header value is optional. This change to emphasize that both the header name and the value are required.

Copy link
Member

Choose a reason for hiding this comment

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

It's technically optional because you can do -Field to delete a header, in which case no value is passed.

Copy link
Author

Choose a reason for hiding this comment

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

Are you talking about the header directive?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, yeah sorry. I didn't click through to the files changed so I didn't notice it was the response matcher in encode. That said, ! as a prefix is allowed, meaning "this header doesn't exist in the response" and in that case you omit the value. See https://caddyserver.com/docs/caddyfile/response-matchers#header

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, didn't know about the ! syntax. I'll revert.

@@ -37,28 +37,43 @@ header [<matcher>] [[+|-|?|>]<field> [<value>|<find>] [<replace>]] {
?<field> <value>

[defer]

# a match condition
match [status <code...> | header <field> <value>]
Copy link
Member

Choose a reason for hiding this comment

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

This one's a bit strange cause it's not optional to provide a matcher, so the [] are sorta misplaced.

I think we should probably replace these to just <response_matcher...> instead, similar to how we have <matcher> in places where a request matcher can go. We can add a jquery blob at the top to transform those into links to https://caddyserver.com/docs/caddyfile/response-matchers

Copy link
Author

Choose a reason for hiding this comment

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

I think that's a good idea. There are two ways in which response matchers can be used. I documented the difference.

encode and headers allow inline matching, intercept requires creating named response matchers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants