diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-25 11:15:26 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-25 11:15:26 +0000 |
commit | 2f11b7cfeeb9a25225c2f31e95afabcd3e43bb41 (patch) | |
tree | 178cbe46704edea6a8d88cd727636ecbb7b2fa73 /actionpack | |
parent | fd67e3befc748e91b4ad0b09be7f3cca69bb7380 (diff) | |
download | rails-2f11b7cfeeb9a25225c2f31e95afabcd3e43bb41.tar.gz rails-2f11b7cfeeb9a25225c2f31e95afabcd3e43bb41.tar.bz2 rails-2f11b7cfeeb9a25225c2f31e95afabcd3e43bb41.zip |
Added @request.raw_post as a convenience access to @request.env['RAW_POST_DATA'] and fixed the patch problems with the session #534 [Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@502 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_controller/cgi_process.rb | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 26 |
4 files changed, 25 insertions, 13 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index a88fb8b65e..f66d6bbd96 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added @request.raw_post as a convenience access to @request.env['RAW_POST_DATA'] #534 [Tobias Luetke] + * Added support for automatic id-based indexing for lists of items #532 [dblack]. Example: <% @students.each do |@student| %> diff --git a/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb b/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb index 706654e52b..ce6722f3a4 100644 --- a/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb +++ b/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb @@ -13,10 +13,12 @@ class CGI #:nodoc: @multipart = false @params = CGI::parse(read_query_params) end + + @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] or env_table['COOKIE'])) end private - MULTIPART_FORM_BOUNDARY_RE = %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n + MULTIPART_FORM_BOUNDARY_RE = %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n #" def multipart_form_boundary if env_table['REQUEST_METHOD'] == 'POST' @@ -27,7 +29,7 @@ class CGI #:nodoc: def read_query_params case env_table['REQUEST_METHOD'] when 'GET', 'HEAD' - if defined? MOD_RUBY + if defined? MOD_RUBY Apache::request.args or '' else env_table['QUERY_STRING'] or '' @@ -41,4 +43,4 @@ class CGI #:nodoc: end end end # module QueryExtension -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index 544863a74e..92b19fbf18 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -1,6 +1,6 @@ require 'action_controller/cgi_ext/cgi_ext' require 'action_controller/cgi_ext/cookie_performance_fix' -# require 'action_controller/cgi_ext/raw_post_data_fix' +require 'action_controller/cgi_ext/raw_post_data_fix' require 'action_controller/session/drb_store' require 'action_controller/session/active_record_store' require 'action_controller/session/mem_cache_store' diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index d3d65ec0ec..94ec7d27af 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -29,7 +29,8 @@ module ActionController def head? method == :head end - + + # Determine originating IP address. REMOTE_ADDR is the standard # but will fail if the user is behind a proxy. HTTP_CLIENT_IP and/or # HTTP_X_FORWARDED_FOR are set by proxies so check for these before @@ -53,40 +54,47 @@ module ActionController # Returns the domain part of a host, such as rubyonrails.org in "www.rubyonrails.org". You can specify # a different <tt>tld_length</tt>, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk". def domain(tld_length = 1) - host.split(".").last(1 + tld_length).join(".") + host.split('.').last(1 + tld_length).join('.') end # Returns all the subdomains as an array, so ["dev", "www"] would be returned for "dev.www.rubyonrails.org". # You can specify a different <tt>tld_length</tt>, such as 2 to catch ["www"] instead of ["www", "rubyonrails"] # in "www.rubyonrails.co.uk". def subdomains(tld_length = 1) - parts = host.split(".") + parts = host.split('.') parts - parts.last(1 + tld_length) end + # Recieve the raw post data. + # This is useful for services such as REST, XMLRPC and SOAP + # which communicate over HTTP POST but don't use the traditional parameter format. + def raw_post + env['RAW_POST_DATA'] + end + def request_uri - env["REQUEST_URI"] + env['REQUEST_URI'] end def protocol - port == 443 ? "https://" : "http://" + port == 443 ? 'https://' : 'http://' end def ssl? - protocol == "https://" + protocol == 'https://' end def path - request_uri ? request_uri.split("?").first : "" + request_uri ? request_uri.split('?').first : '' end def port - env["SERVER_PORT"].to_i + env['SERVER_PORT'].to_i end # Returns a string like ":8080" if the port is not 80 or 443 while on https. def port_string - (protocol == "http://" && port == 80) || (protocol == "https://" && port == 443) ? "" : ":#{port}" + (protocol == 'http://' && port == 80) || (protocol == 'https://' && port == 443) ? '' : ":#{port}" end def host_with_port |