aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/cgi_process.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-15 21:36:21 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-15 21:36:21 +0000
commit32d03af341eba4d0b263156f0241016b857c4d84 (patch)
tree5638dfcd579382a3de546f9fc3b5f3b94473f1ef /actionpack/lib/action_controller/cgi_process.rb
parent9e3a51eb6cc6f54c861c808c15bf8895d14aa023 (diff)
downloadrails-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.rb12
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