Class | ActionController::AbstractRequest
In: | lib/action_controller/deprecated_request_methods.rb lib/action_controller/request.rb
Parent: | Object

Subclassing AbstractRequest makes these methods available to the request objects used in production and testing, CgiRequest and TestRequest

### Methods

accepts content_type delete? domain formatted_post? get? head? host host_with_port method parameters path path_parameters port port_string post? post_format protocol put? raw_post relative_url_root remote_ip request_uri server_software ssl? standard_port subdomains symbolized_path_parameters xhr? xml_http_request? xml_post? yaml_post?

### Attributes

env | [R] | Returns the hash of environment variables for this request, such as { ‘RAILS_ENV’ => ‘production’ }.

### Public Instance methods

accepts()

Returns the accepted MIME type for the request

content_type()

Determine whether the body of a HTTP call is URL-encoded (default) or matches one of the registered param_parsers.

For backward compatibility, the post format is extracted from the X-Post-Data-Format HTTP header if present.

delete?()

Is this a DELETE request? Equivalent to request.method == :delete

domain(tld_length = 1)

Returns the domain part of a host, such as rubyonrails.org in "www.rubyonrails.org". You can specify a different `tld_length`, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk".

formatted_post?()

Is this a POST request formatted as XML or YAML?

get?()

Is this a GET request? Equivalent to request.method == :get

head?()

Is this a HEAD request? Equivalent to request.method == :head

host()

Returns the host for this request, such as example.com.

host_with_port()

Returns a host:port string for this request, such as example.com or example.com:8080.

method()

Returns the HTTP request method as a lowercase symbol (:get, for example)

parameters()

Returns both GET and POST parameters in a single hash.

path()

Returns the interpreted path to requested resource after all the installation directory of this application was taken into account

path_parameters()

Returns a hash with the parameters used to form the path of the request

Example:

      {:action => 'my_action', :controller => 'my_controller'}

port()

Returns the port number of this request as an integer.

port_string()

Returns a port suffix like ":8080" if the port number of this request is not the default HTTP port 80 or HTTPS port 443.

post?()

Is this a POST request? Equivalent to request.method == :post

post_format()

Determine whether the body of a HTTP call is URL-encoded (default) or matches one of the registered param_parsers.

For backward compatibility, the post format is extracted from the X-Post-Data-Format HTTP header if present.

protocol()

Return ‘https://’ if this is an SSL request and ‘http://’ otherwise.

put?()

Is this a PUT request? Equivalent to request.method == :put

raw_post()

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.

relative_url_root()

Returns the path minus the web server relative installation directory. This can be set with the environment variable RAILS_RELATIVE_URL_ROOT. It can be automatically extracted for Apache setups. If the server is not Apache, this method returns an empty string.

remote_ip()

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 falling back to REMOTE_ADDR. HTTP_X_FORWARDED_FOR may be a comma- delimited list in the case of multiple chained proxies; the first is the originating IP.

request_uri()

Returns the request URI correctly, taking into account the idiosyncracies of the various servers.

server_software()

Returns the lowercase name of the HTTP server software.

ssl?()

Is this an SSL request?

standard_port()

Returns the standard port number for this request‘s protocol

subdomains(tld_length = 1)

Returns all the subdomains as an array, so ["dev", "www"] would be returned for "dev.www.rubyonrails.org". You can specify a different `tld_length`, such as 2 to catch ["www"] instead of ["www", "rubyonrails"] in "www.rubyonrails.co.uk".

symbolized_path_parameters()

The same as `path_parameters` with explicitly symbolized keys

xhr?()

Alias for xml_http_request?

xml_http_request?()

Returns true if the request‘s "X-Requested-With" header contains "XMLHttpRequest". (The Prototype Javascript library sends this header with every Ajax request.)

xml_post?()

Is this a POST request formatted as XML?

yaml_post?()

Is this a POST request formatted as YAML?

[Validate]