-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Grape allows invalid headers to be set. #2334
Comments
For Grape users, is the real issue is that it works in Grape with Rack 2.x and not 3.x causing a |
Other breaking changes with Rack 3, #2298. |
No, it's nothing to do with Rack 3, it's always been invalid, even Rack 2 spec does not allow non-string header values. |
But it works for users today, except when otherwise (described in socketry/protocol-rack#2). I think Grape should adhere to spec. I like the option of doing |
If you put I think you should encourage people to use |
Fixes ruby-grape#2334 Ensure all header values are strings according to the Rack spec. * Convert header values to strings using `to_s` in the `header` method in `lib/grape/dsl/headers.rb`. * Emit a warning if the header value is not a string in the `header` method in `lib/grape/dsl/headers.rb`. * Add tests in `spec/grape/dsl/headers_spec.rb` to verify that non-string header values are converted to strings and warnings are emitted. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ruby-grape/grape/issues/2334?shareId=XXXX-XXXX-XXXX-XXXX).
Fixes ruby-grape#2334 Ensure all header values are strings according to the Rack spec. * Convert header values to strings using `to_s` in the `header` method in `lib/grape/dsl/headers.rb`. * Emit a warning if the header value is not a string in the `header` method in `lib/grape/dsl/headers.rb`. * Add tests in `spec/grape/dsl/headers_spec.rb` to verify that non-string header values are converted to strings and warnings are emitted. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ruby-grape/grape/issues/2334?shareId=XXXX-XXXX-XXXX-XXXX).
Follow up from socketry/protocol-rack#2 (comment).
The following implementation allows non-string header values.
grape/lib/grape/dsl/headers.rb
Line 13 in d1dfdcc
Technically, all headers should be strings, according to the rack spec.
I'm not sure if we should change this. I see several options:
@header
key values to string values, (or array of string values, allowed by Rack 3+).The text was updated successfully, but these errors were encountered: