Class

AbstractRequest

Extends:

CgiRequest and TestRequest provide concrete implementations.

Constants
EOL
MULTIPART_BOUNDARY
Public Attributes
env The hash of environment variables for this request, such as { ‘RAILS_ENV’ => ‘production’ }.
Public Methods
accepts Returns the accepted MIME type for the request
body The request body is an IO input stream.
content_length
content_type The MIME type of the HTTP request, such as Mime::XML.
cookies
delete? Is this a DELETE request? Equivalent to request.method == :delete
domain 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".
format 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:
format= Sets the format by string extension, which can be used to force custom formats that are not controlled by the extension. Example:
get? Is this a GET (or HEAD) request? Equivalent to request.method == :get
head? Is this a HEAD request? request.method sees HEAD as :get, so check the HTTP method directly.
headers
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 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.
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. Returned hash keys are strings. See symbolized_path_parameters for symbolized keys.
path_parameters=
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
protocol Return ‘https://’ if this is an SSL request and ‘http://’ otherwise.
put? Is this a PUT request? Equivalent to request.method == :put
query_parameters
query_string Return the query string, accounting for server idiosyncracies.
raw_post Read the request body. This is useful for web services that need to work with raw requests directly.
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_method The true HTTP request method as a lowercase symbol, such as :get. UnknownHttpMethod is raised for invalid methods not listed in ACCEPTED_HTTP_METHODS.
request_parameters
request_uri Return the request URI, accounting for server idiosyncracies. WEBrick includes the full URL. IIS leaves REQUEST_URI blank.
reset_session
server_software Returns the lowercase name of the HTTP server software.
session
session=
ssl? Is this an SSL request?
standard_port Returns the standard port number for this request’s protocol
subdomains 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
url Returns the complete URL used for this request
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.)
Protected Methods
content_type_with_parameters 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.
content_type_without_parameters The raw content type string with its parameters stripped off.
Private Methods
clean_up_ajax_request_body!
content_type_from_legacy_post_data_format_header
extract_content_type_without_parameters
extract_multipart_boundary
get_typed_value
named_host?
parse_formatted_request_parameters
parse_multipart_form_parameters
parse_query_parameters
parse_request_parameters
read_multipart
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.