Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/trunk/actionpack/lib/action_controller/cgi_ext/stdinput.rb

Revision 6740, 0.6 kB (checked in by bitsweat, 2 years ago)

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.

Line 
1 require 'cgi'
2
3 module ActionController
4   module CgiExt
5     # Publicize the CGI's internal input stream so we can lazy-read
6     # request.body. Make it writable so we don't have to play $stdin games.
7     module Stdinput
8       def self.included(base)
9         base.class_eval do
10           remove_method :stdinput
11           attr_accessor :stdinput
12         end
13
14         base.alias_method_chain :initialize, :stdinput
15       end
16
17       def initialize_with_stdinput(type = nil, stdinput = $stdin)
18         @stdinput = stdinput
19         initialize_without_stdinput(type || 'query')
20       end
21     end
22   end
23 end
Note: See TracBrowser for help on using the browser.