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

Implemented validation on request header keys on Req.new #211

Closed
wants to merge 2 commits into from

Conversation

octowombat
Copy link

@octowombat octowombat commented Jul 31, 2023

Not sure if I put the logic in the best place but it's where I thought it made sense to me!

Signed-off-by: Willy Wombat <octowombat@gmail.com>
Signed-off-by: Willy Wombat <octowombat@gmail.com>
@wojtekmach
Copy link
Owner

wojtekmach commented Aug 10, 2023

Thank you for the PR. It looks good to me, I'm just still trying to figure out whether we should only do the checking on Req.new (and thus on Req.get, Req.post, etc too) or everywhere, including the lower-level Req.Request.* functions.

@wojtekmach
Copy link
Owner

wojtekmach commented Aug 25, 2023

@octowombat thank you for pursuing this. This gave me a lot to think about. I decided to:

  1. always downcase header names
  2. warn if they aren't downcased

This is done in #227.

My critical insight was if we ever want to change the behaviour (e.g. noop for maximum performance, raise, etc) it should be done by a compile-time configuration. That is, the __encode_header_name__/1 that I introduced in the PR would become a macro that would return argument as is in :noop mode, generate code that checks and warns at runtime in other mode, etc.

I'm sorry that I won't be merging your PR but it really was very influential, all the edge cases you explored in docs and tests.

@wojtekmach wojtekmach closed this Aug 25, 2023
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