mirror of
https://github.com/github/rails.git
synced 2026-02-19 02:14:20 -05:00
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
This commit is contained in:
@@ -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| %>
|
||||
|
||||
@@ -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
|
||||
end
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user