Skip to content

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
* [#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
ericproulx added a commit to ericproulx/grape that referenced this pull request Jun 22, 2025
* Move HTTP_HEADERS in Grape::Request and renew known headers Use plain HTTP_ or real header name instead of referencing to Http::Headers:: Remove Grape::Util::Lazy::Object * Add few headers * Add other headers * Add other known headers and sort * CHANGELOG.md entry * Fix CHANGELOG.md Add UPGRADING notes Add X-Access-Token in list of headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants