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

[FIX #331] Add simultaneous support for Rack 2 and 3 #332

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

JoeDupuis
Copy link

@JoeDupuis JoeDupuis commented Aug 22, 2023

Context

#318 introduced a regression (#331) for apps running Rack 2.
Rack 3 follows the HTTP 2 spec and requires lower case headers.

By using the Rack header constants we get the correct capitalization regardless of which rack version is loaded.

Considerations

  • I decided to use the rack constants directly. If lower coupling to rack is desired I can edit the PR to add a constant file instead.
  • CI tests both Rack 2 and Rack 3, but didn't raise a failure. There is probably a gap in the test suite.

@JoeDupuis JoeDupuis changed the title [FIX #331] Add simultaneous support for both Rack 2 and 3 [FIX #331] Add simultaneous support for Rack 2 and 3 Aug 22, 2023
@@ -52,7 +52,7 @@ def call(env)
private

def acceptable_content_type?(headers)
headers["content-type"].to_s.include?("html")
headers[Rack::CONTENT_TYPE].to_s.include?("html")
Copy link
Member

Choose a reason for hiding this comment

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

There's another "content-type" 5 lines below

Copy link
Author

@JoeDupuis JoeDupuis Aug 22, 2023

Choose a reason for hiding this comment

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

The other one was not causing an issue, since we had no conditional on it, but I updated it and the other references too for the sake of consistency. They were mostly tests.

I left this one
I see it as separate since It's on the request side. Just like we can't control the casing from a browser request.
It's in an ERB file, so we could use same constant, but it would make the code a bit uglier.
Do you prefer to change it too?

Copy link
Member

Choose a reason for hiding this comment

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

No, I agree with you that one should be fine since its a request header (Rack 3 only requires response headers to be downcasesd)

[rails#318] introduced a [regression](rails#331) for apps running Rack 2.
Rack 3 follows the http 2 spec and requires lowercase headers.
By using the Rack header constants we get the correct capitalization
regardless of which rack version is loaded.
@gsamokovarov
Copy link
Collaborator

Thanks!

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.

None yet

3 participants