Skip to content

Remove Grape::Http::Headers #2554

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

Merged
merged 8 commits into from
Apr 10, 2025
Merged

Conversation

ericproulx
Copy link
Contributor

@ericproulx ericproulx commented Apr 5, 2025

This PR removes Grape::Http::Headers. Since most constants HTTP_ were just literal string and Grape's uses #frozen_string_literal: true, it made sense to just use the literal string wherever needed. Here's a list of notable changes:

  • Grape::Http::Headers::SUPPORTED_METHODS has been moved to Grape module.
  • Grape::Http::Headers::HTTP_HEADERS has been moved to Grape::Request and its now called KNOWN_HEADERS. The last has been revisited to reflect Rack 3's KNOWN_HEADERS. Its not an exact copy. Grape's version has more.
  • Grape::Util::Lazy::Object no longer exists. Solely used by Grape::Http::Headers::HTTP_HEADERS
  • Grape::Http::Headers.find_supported_method no long exists. It wasn't used.
  • Removes to_s when calling headers since its not just a plain {} but a Grape::Util::Headers. Fix Grape allows invalid headers to be set. #2334
  • Closes Fix Grape allowing invalid headers to be set #2511

Use plain HTTP_ or real header name instead of referencing to Http::Headers::
Remove Grape::Util::Lazy::Object
@ericproulx ericproulx changed the title Refactor http headers Remove Grape::Http::Headers Apr 5, 2025
@ericproulx ericproulx requested a review from dblock April 5, 2025 14:50
@ericproulx ericproulx marked this pull request as ready for review April 5, 2025 14:50
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I think this needs an UPGRADING on the invalid header that can be set and the removal of some constants.

CHANGELOG.md Outdated
@@ -9,6 +9,7 @@
* [#2540](https://github.com/ruby-grape/grape/pull/2540): Introduce Params builder with symbolized short name - [@ericproulx](https://github.com/ericproulx).
* [#2550](https://github.com/ruby-grape/grape/pull/2550): Drop ActiveSupport 6.0 - [@ericproulx](https://github.com/ericproulx).
* [#2549](https://github.com/ruby-grape/grape/pull/2549): Delegate cookies management to `Grape::Request` - [@ericproulx](https://github.com/ericproulx).
* [#2554](https://github.com/ruby-grape/grape/pull/2554): Remove Grape::Http::Headers - [@ericproulx](https://github.com/ericproulx).
Copy link
Member

Choose a reason for hiding this comment

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

I think you have a fix here for #2334, add?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well its a fix .. but not really. We've been using Grape::Util::Header for a while and since then, Grape is compliant with Rack's spec about headers.

Add UPGRADING notes
Add X-Access-Token in list of headers
@ericproulx ericproulx requested a review from dblock April 7, 2025 19:46
@dblock
Copy link
Member

dblock commented Apr 9, 2025

Rebase? Feel free to merge yourself.

@dblock dblock merged commit 1a75b28 into ruby-grape:master Apr 10, 2025
63 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.

Grape allows invalid headers to be set.
2 participants