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

Add :downcase_request_headers option to HTTP1.connect #399

Merged
merged 12 commits into from
Feb 12, 2024

Conversation

DunyaKokoschka
Copy link
Contributor

i hear you want not lower header. i give you not lower header. but also i make default headers not lower if you pass
in not lower option. alexi say this change is slow. i tell alexi if you care about slow why using elixir.

#256

@whatyouhide
Copy link
Contributor

Do you know if this is a behavior that we should have for HTTP/2 as well?

@ericmj
Copy link
Member

ericmj commented Apr 24, 2023

Do you know if this is a behavior that we should have for HTTP/2 as well?

I would say no until proven otherwise. AFAIK all HTTP/2 implementers properly handle header casing.

@DunyaKokoschka
Copy link
Contributor Author

I've added some commits which address the comments. The name of the option is currently case_sensitive_headers. And I added the docs for the option to the Mint.HTTP1.connect method. I'm not sure if this is the correct place. I wasn't so sure about this comment: case_sensitive_headers

Also, locally the twitter integration test is failing for me with a 302 instead of a 200.

@coveralls
Copy link

coveralls commented May 10, 2023

Pull Request Test Coverage Report for Build af90beafc56cae431db21473789a981195337f07-PR-399

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 20 of 20 (100.0%) changed or added relevant lines in 5 files are covered.
  • 62 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.05%) to 87.674%

Files with Coverage Reduction New Missed Lines %
lib/mint/core/util.ex 2 91.3%
lib/mint/http2.ex 3 94.35%
lib/mint/http1/response.ex 4 69.23%
lib/mint/http.ex 13 62.86%
lib/mint/http1.ex 40 83.86%
Totals Coverage Status
Change from base Build 301b77910b131541c11ef8b34d8d6f6b7c0583d1: 0.05%
Covered Lines: 1259
Relevant Lines: 1436

💛 - Coveralls

@ericmj ericmj force-pushed the preserve_header_case branch from 33207b8 to 8fd0806 Compare February 11, 2024 21:24
@ericmj
Copy link
Member

ericmj commented Feb 11, 2024

@whatyouhide I rebased and did some clean up. Do you think we are good to merge this?


* `:case_sensitive_headers` - (boolean) if set to true the case of the supplied
headers in requests will be preserved. The default is to lowercase the headers
because http/1.1 header names are not case-insensitive.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
because http/1.1 header names are not case-insensitive.
because HTTP/1.1 header names are case-sensitive.

Copy link
Member

Choose a reason for hiding this comment

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

Oh wait. This text is even wrong, we can lower because they are in fact case-insensitive.

{original_name :: String.t(), canonical_name :: String.t(), value :: String.t()}
@type raw_header() :: {original_name :: String.t(), value :: String.t()}

@unallowed_trailer_headers MapSet.new([
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe I mentioned it on some other occasion: "trailer headers" feels like a misnomer. Quickly looking at RFC 7231 the naming didn't seem to be super explicit, but in the newer one that surpasses it, RFC 9110, it is: http has fields: header fields (colloquially "headers") and trailer fields (colloquially "trailers")

I only mention this as an offer to send a patch to use "trailers" or "trailer fields" naming internally. It's probably not worth it to go through deprecations if the trailer_headers name was used in public APIs so I wouldn't touch these.

Feel free to ignore, it's not a big deal in the grand scheme of things. :)

Copy link
Contributor

@whatyouhide whatyouhide left a comment

Choose a reason for hiding this comment

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

Beautiful Eric, couple of comments but we can finally ship this, exciting!!

@ericmj ericmj force-pushed the preserve_header_case branch from ef3da3e to 17d2697 Compare February 12, 2024 13:27
@ericmj ericmj changed the title Add :downcase_request_headers option to HTTP1.connect to not downcase… Add :downcase_request_headers option to HTTP1.connect Feb 12, 2024
@ericmj ericmj merged commit 74e0ec6 into elixir-mint:main Feb 12, 2024
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.

5 participants