forked from soveran/cuba
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make json_parser plugin handle case where Rack::Request#POST is calle…
…d previously for env on Rack 3 (Fixes #372) The Rack 1-2 behavior did not cache rack.request.form_hash values for data it didn't understand. That changed in Rack 3, to fix a bug in Rack that was open since 2014. This updates the code to work with all versions of Rack. It now never checks rack.request.form_hash or sets rack.request.form_input. This approach is slightly slower for r.POST when given non-JSON input, because it now checks the content_type when previously it did not. Unfortunately, I don't see a way to avoid that. I did make the check faster by switching from a regexp to using String#include?. In most cases, r.POST performance doesn't matter, as users typically use r.params, and that is cached via an instance variable, so r.POST is generally only called once per request.
- Loading branch information
1 parent
7ddfb97
commit eb7843c
Showing
4 changed files
with
36 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters