diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-15 21:36:21 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-15 21:36:21 +0000 |
commit | 32d03af341eba4d0b263156f0241016b857c4d84 (patch) | |
tree | 5638dfcd579382a3de546f9fc3b5f3b94473f1ef /actionpack/lib/action_controller/cgi_process.rb | |
parent | 9e3a51eb6cc6f54c861c808c15bf8895d14aa023 (diff) | |
download | rails-32d03af341eba4d0b263156f0241016b857c4d84.tar.gz rails-32d03af341eba4d0b263156f0241016b857c4d84.tar.bz2 rails-32d03af341eba4d0b263156f0241016b857c4d84.zip |
Introduce the request.body stream. Lazy-read to parse parameters rather than always setting RAW_POST_DATA. Reduces the memory footprint of large binary PUT requests.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6740 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/cgi_process.rb')
-rw-r--r-- | actionpack/lib/action_controller/cgi_process.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index 59849c7364..ee6e5ca250 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -58,6 +58,16 @@ module ActionController #:nodoc: end end + # The request body is an IO input stream. If the RAW_POST_DATA environment + # variable is already set, wrap it in a StringIO. + def body + if raw_post = env['RAW_POST_DATA'] + StringIO.new(raw_post) + else + @cgi.stdinput + end + end + def query_parameters @query_parameters ||= (qs = self.query_string).empty? ? {} : CGI.parse_query_parameters(qs) @@ -66,7 +76,7 @@ module ActionController #:nodoc: def request_parameters @request_parameters ||= if ActionController::Base.param_parsers.has_key?(content_type) - CGI.parse_formatted_request_parameters(content_type, @env['RAW_POST_DATA']) + CGI.parse_formatted_request_parameters(content_type, body.read) else CGI.parse_request_parameters(@cgi.params) end |