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.

lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
test/mint/http1/conn_test.exs Outdated Show resolved Hide resolved
lib/mint/http1.ex Outdated Show resolved Hide resolved
lib/mint/http1.ex Outdated Show resolved Hide resolved
lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
lib/mint/http1/headers.ex Outdated Show resolved Hide resolved
@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 17d2697acfe911fefda4291ee5a04f392057aa6b-PR-399

Details

  • -1 of 55 (98.18%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 87.509%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/mint/core/headers.ex 18 19 94.74%
Totals Coverage Status
Change from base Build ce8102b57a9bf8b4159cd0096b31d08b5d70ad09: 0.08%
Covered Lines: 1268
Relevant Lines: 1449

💛 - Coveralls

@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!!

lib/mint/core/headers.ex Outdated Show resolved Hide resolved
lib/mint/core/headers.ex Outdated Show resolved Hide resolved
lib/mint/core/headers.ex Outdated Show resolved Hide resolved
@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
4 checks passed
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