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

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

Revision 6764, 0.7 kB (checked in by bitsweat, 2 years ago)

Parse url-encoded and multipart requests ourselves instead of delegating to CGI.

Line 
1 require 'cgi'
2
3 class CGI #:nodoc:
4   module QueryExtension
5     # Remove the old initialize_query method before redefining it.
6     remove_method :initialize_query
7
8     # Neuter CGI parameter parsing.
9     def initialize_query
10       # Fix some strange request environments.
11       env_table['REQUEST_METHOD'] ||= 'GET'
12
13       # POST assumes missing Content-Type is application/x-www-form-urlencoded.
14       if env_table['CONTENT_TYPE'].blank? && env_table['REQUEST_METHOD'] == 'POST'
15         env_table['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
16       end
17
18       @cookies = CGI::Cookie::parse(env_table['HTTP_COOKIE'] || env_table['COOKIE'])
19       @params = {}
20     end
21   end
22 end
Note: See TracBrowser for help on using the browser.