Class | ActionController::AbstractRequest |
In: |
lib/action_controller/request.rb
|
Parent: | Object |
CgiRequest and TestRequest provide concrete implementations.
MULTIPART_BOUNDARY | = | %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n |
EOL | = | "\015\012" |
env | [R] | The hash of environment variables for this request, such as { ‘RAILS_ENV’ => ‘production’ }. |
The MIME type of the HTTP request, such as Mime::XML.
For backward compatibility, the post format is extracted from the X-Post-Data-Format HTTP header if present.
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".
Returns the Mime type for the format used in the request. If there is no format available, the first of the accept types will be used. Examples:
GET /posts/5.xml | request.format => Mime::XML GET /posts/5.xhtml | request.format => Mime::HTML GET /posts/5 | request.format => request.accepts.first (usually Mime::HTML for browsers)
Sets the format by string extension, which can be used to force custom formats that are not controlled by the extension. Example:
class ApplicationController < ActionController::Base before_filter :adjust_format_for_iphone private def adjust_format_for_iphone request.format = :iphone if request.env["HTTP_USER_AGENT"][/iPhone/] end end
Is this a HEAD request? request.method sees HEAD as :get, so check the HTTP method directly.
The HTTP request method as a lowercase symbol, such as :get. Note, HEAD is returned as :get since the two are functionally equivalent from the application‘s perspective.
Returns the interpreted path to requested resource after all the installation directory of this application was taken into account
Returns a hash with the parameters used to form the path of the request. Returned hash keys are strings. See symbolized_path_parameters for symbolized keys.
Example:
{'action' => 'my_action', 'controller' => 'my_controller'}
Read the request body. This is useful for web services that need to work with raw requests directly.
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.
Security note: do not use if IP spoofing is a concern for your application. Since remote_ip checks HTTP headers for addresses forwarded by proxies, the client may send any IP. remote_addr can‘t be spoofed but also doesn‘t work behind a proxy, since it‘s always the proxy‘s IP.
The true HTTP request method as a lowercase symbol, such as :get. UnknownHttpMethod is raised for invalid methods not listed in ACCEPTED_HTTP_METHODS.
Return the request URI, accounting for server idiosyncracies. WEBrick includes the full URL. IIS leaves REQUEST_URI blank.
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".
Returns true if the request‘s "X-Requested-With" header contains "XMLHttpRequest". (The Prototype Javascript library sends this header with every Ajax request.)
The raw content type string. Use when you need parameters such as charset or boundary which aren‘t included in the content_type MIME type. Overridden by the X-POST_DATA_FORMAT header for backward compatibility.