diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-11-24 01:04:44 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-11-24 01:04:44 +0000 |
commit | db045dbbf60b53dbe013ef25554fd013baf88134 (patch) | |
tree | 257830e3c76458c8ff3d1329de83f32b23926028 /actionpack/lib/action_controller/cgi_ext/cgi_ext.rb | |
download | rails-db045dbbf60b53dbe013ef25554fd013baf88134.tar.gz rails-db045dbbf60b53dbe013ef25554fd013baf88134.tar.bz2 rails-db045dbbf60b53dbe013ef25554fd013baf88134.zip |
Initial
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/cgi_ext/cgi_ext.rb')
-rwxr-xr-x | actionpack/lib/action_controller/cgi_ext/cgi_ext.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb b/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb new file mode 100755 index 0000000000..371ead695b --- /dev/null +++ b/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb @@ -0,0 +1,43 @@ +require 'cgi' +require 'cgi/session' +require 'cgi/session/pstore' +require 'action_controller/cgi_ext/cgi_methods' + +# Wrapper around the CGIMethods that have been secluded to allow testing without +# an instatiated CGI object +class CGI #:nodoc: + class << self + alias :escapeHTML_fail_on_nil :escapeHTML + + def escapeHTML(string) + escapeHTML_fail_on_nil(string) unless string.nil? + end + end + + # Returns a parameter hash including values from both the request (POST/GET) + # and the query string with the latter taking precedence. + def parameters + request_parameters.update(query_parameters) + end + + def query_parameters + CGIMethods.parse_query_parameters(query_string) + end + + def request_parameters + CGIMethods.parse_request_parameters(params) + end + + def redirect(where) + header({ + "Status" => "302 Moved", + "location" => "#{where}" + }) + end + + def session(parameters = nil) + parameters = {} if parameters.nil? + parameters['database_manager'] = CGI::Session::PStore + CGI::Session.new(self, parameters) + end +end
\ No newline at end of file |