aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/cgi_ext/stdinput.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_ext/stdinput.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_ext/stdinput.rb')
-rw-r--r--actionpack/lib/action_controller/cgi_ext/stdinput.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/stdinput.rb b/actionpack/lib/action_controller/cgi_ext/stdinput.rb
new file mode 100644
index 0000000000..b0ca63ef2f
--- /dev/null
+++ b/actionpack/lib/action_controller/cgi_ext/stdinput.rb
@@ -0,0 +1,23 @@
+require 'cgi'
+
+module ActionController
+ module CgiExt
+ # Publicize the CGI's internal input stream so we can lazy-read
+ # request.body. Make it writable so we don't have to play $stdin games.
+ module Stdinput
+ def self.included(base)
+ base.class_eval do
+ remove_method :stdinput
+ attr_accessor :stdinput
+ end
+
+ base.alias_method_chain :initialize, :stdinput
+ end
+
+ def initialize_with_stdinput(type = nil, stdinput = $stdin)
+ @stdinput = stdinput
+ initialize_without_stdinput(type || 'query')
+ end
+ end
+ end
+end