Closed everton closed 1 year ago
The original class was added in response to #218, but I'm not sure the original problem still exists since some efforts to downcase the header keys were already made.
Just removing the line with the code (replace Rack::Utils::HeaderHash.new(h) by return h in lib/rack/cors/resource.rb) apparently works (tested only locally and in a very simple case and no tests were broken).
Is this a possible solution, or are there other implications that should require using the Rack: :Headers class?
@everton thanks for the detailed report. It looks like the HeaderHash is no longer needed in rack 3 since it lower cases header keys on its own. I see two ways of fixing this:
defined?
check on HeaderHash and use it if defined. This way we can maintain rack 2 compatibilityIs there another possibility I'm missing?
Just removing the class would not break the previous compatibility (your code didn't have this class until last year and it was working).
What would happen is that the problem described would be reintroduced, which sincerely seems to be ok, because if anyone had any problem with it they will have 2 options:
@everton Ok, happy to take this change if you will create a PR.
Added PR #252, where I just removed the Rack::Utils::HeaderHash.new, making it equal to the original code where the hash "h" was just returned without any transformation.
Should this be closed now that #252 is merged?
Sure, thanks for remembering this.
The Rack::Utils::HeaderHash was removed by Rack on the commit:
https://github.com/rack/rack/commit/a5762cf60af474b89b555ff8d151be5a021701f8#diff-85960cbd609e7f51a9881d1876b82d748f4ba8312a31e3329a5bb9bf791c60be
In the (previously existing) deprecation warning, they suggest "switch to Rack::Headers"; Testing it using this class apparently works, but I'm not sure if you feel it is the proper change since I don't know if the original motivation to use the HeaderHash still exists today.