Permalink
Browse files

r3201@asus: jeremy | 2005-11-19 21:31:47 -0800

 Apply [3103] to stable.  Document request.env and request.host.  Strip trailing whitespace.


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@3104 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 54977e0 commit 1aac21ca24732a24df5cdff1ca7baa7fd2a47f23 @jeremy jeremy committed Nov 20, 2005
Showing with 18 additions and 15 deletions.
  1. +18 −15 actionpack/lib/action_controller/request.rb
@@ -2,7 +2,7 @@ module ActionController
# These methods are available in both the production and test Request objects.
class AbstractRequest
cattr_accessor :relative_url_root
-
+
# Returns both GET and POST parameters in a single hash.
def parameters
@parameters ||= request_parameters.merge(query_parameters).merge(path_parameters).with_indifferent_access
@@ -110,7 +110,7 @@ def remote_ip
# a different <tt>tld_length</tt>, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk".
def domain(tld_length = 1)
return nil if !/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.match(host).nil? or host.nil?
-
+
host.split('.').last(1 + tld_length).join('.')
end
@@ -123,13 +123,13 @@ def subdomains(tld_length = 1)
parts[0..-(tld_length+2)]
end
- # Receive 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.
+ # Receive 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
-
+
# Returns the request URI correctly, taking into account the idiosyncracies
# of the various servers.
def request_uri
@@ -153,9 +153,9 @@ def protocol
# Is this an SSL request?
def ssl?
- env['HTTPS'] == 'on'
+ env['HTTPS'] == 'on'
end
-
+
# Returns the interpreted path to requested resource after all the installation directory of this application was taken into account
def path
path = (uri = request_uri) ? uri.split('?').first : ''
@@ -165,7 +165,7 @@ def path
path[0, root.length] = '' if root
path || ''
end
-
+
# Returns the path minus the web server relative installation directory.
# This method returns nil unless the web server is apache.
def relative_url_root
@@ -176,7 +176,7 @@ def relative_url_root
def port
@port_as_int ||= env['SERVER_PORT'].to_i
end
-
+
# Returns the standard port number for this request's protocol
def standard_port
case protocol
@@ -196,12 +196,12 @@ def port_string
def host_with_port
host + port_string
end
-
+
def path_parameters=(parameters)
@path_parameters = parameters
@symbolized_path_parameters = @parameters = nil
end
-
+
def symbolized_path_parameters
@symbolized_path_parameters ||= path_parameters.symbolize_keys
end
@@ -224,10 +224,13 @@ def query_parameters #:nodoc:
def request_parameters #:nodoc:
end
- def env #:nodoc:
+ # Returns the hash of environment variables for this request,
+ # such as { 'RAILS_ENV' => 'production' }.
+ def env
end
- def host #:nodoc:
+ # Returns the host for this request, such as example.com.
+ def host
end
def cookies #:nodoc:
@@ -237,6 +240,6 @@ def session #:nodoc:
end
def reset_session #:nodoc:
- end
+ end
end
end

0 comments on commit 1aac21c

Please sign in to comment.