Created
August 20, 2011 22:18
-
-
Save notch8-old/1159738 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Returns the data recieved in the request body. | |
| # | |
| # This method support both application/x-www-form-urlencoded and | |
| # multipart/form-data. | |
| def POST | |
| if @env["rack.input"].nil? | |
| raise "Missing rack.input" | |
| elsif @env["rack.request.form_input"].eql? @env["rack.input"] | |
| @env["rack.request.form_hash"] | |
| elsif form_data? || parseable_data? | |
| @env["rack.request.form_input"] = @env["rack.input"] | |
| unless @env["rack.request.form_hash"] = parse_multipart(env) | |
| form_vars = @env["rack.input"].read | |
| # Fix for Safari Ajax postings that always append \0 | |
| # form_vars.sub!(/\0\z/, '') # performance replacement: | |
| form_vars.slice!(-1) if form_vars[-1] == ?\0 | |
| @env["rack.request.form_vars"] = form_vars | |
| @env["rack.request.form_hash"] = parse_query(form_vars) | |
| @env["rack.input"].rewind | |
| end | |
| @env["rack.request.form_hash"] | |
| else | |
| {} | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment