Class

Rack::Request

Inheritance
< Object

Rack::Request provides a convenient interface to a Rack environment. It is stateless, the environment env passed to the constructor will be directly modified.

  req = Rack::Request.new(env)
  req.post?
  req.params["data"]

The environment hash passed will store a reference to the Request object instantiated so that it will only instantiate if an instance of the Request object doesn‘t already exist.

Constants

Name   Description
FORM_DATA_MEDIA_TYPES = [ nil, 'application/x-www-form-urlencoded', 'multipart/form-data' The set of form-data media-types. Requests that do not indicate one of the media types presents in this list will not be eligible for form-data / param parsing.

Attributes

Name Visibility R/W Description
env public R The environment of the request.

Methods

Class

Visibility Signature
public new (env)
public new (env)

Instance

Visibility Signature
public GET ()
public POST ()
public [] (key)
public []= (key, value)
public accept_encoding ()
public body ()
public content_charset ()
public content_length ()
public content_type ()
public cookies ()
public delete? ()
public form_data? ()
public fullpath ()
public get? ()
public head? ()
public host ()
public ip ()
public media_type ()
public media_type_params ()
public openid_request ()
public openid_response ()
public params ()
public path_info ()
public path_info= (s)
public port ()
public post? ()
public put? ()
public query_string ()
public referer ()
public referrer ()
public request_method ()
public scheme ()
public script_name ()
public script_name= (s)
public url ()
public values_at (*keys)
public xhr? ()

Class Method Detail

new(env)

new(env)

Instance Method Detail

GET()

Returns the data recieved in the query string.

POST()

Returns the data recieved in the request body.

This method support both application/x-www-form-urlencoded and multipart/form-data.

[](key)

shortcut for request.params[key]

[]=(key, value)

shortcut for request.params[key] = value

accept_encoding()

body()

content_charset()

The character set of the request body if a "charset" media type parameter was given, or nil if no "charset" was specified. Note that, per RFC2616, text/* media types that specify no explicit charset are to be considered ISO-8859-1.

content_length()

content_type()

cookies()

delete?()

form_data?()

Determine whether the request body contains form-data by checking the request media_type against registered form-data media-types: "application/x-www-form-urlencoded" and "multipart/form-data". The list of form-data media types can be modified through the FORM_DATA_MEDIA_TYPES array.

fullpath()

get?()

head?()

host()

ip()

media_type()

The media type (type/subtype) portion of the CONTENT_TYPE header without any media type parameters. e.g., when CONTENT_TYPE is "text/plain;charset=utf-8", the media-type is "text/plain".

For more information on the use of media types in HTTP, see: www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7

media_type_params()

The media type parameters provided in CONTENT_TYPE as a Hash, or an empty Hash if no CONTENT_TYPE or media-type parameters were provided. e.g., when the CONTENT_TYPE is "text/plain;charset=utf-8", this method responds with the following Hash:

  { 'charset' => 'utf-8' }

openid_request()

openid_response()

params()

The union of GET and POST data.

path_info()

path_info=(s)

port()

post?()

put?()

query_string()

referer()

the referer of the client or ’/’

referrer()

Alias for referer

request_method()

scheme()

script_name()

script_name=(s)

url()

Tries to return a remake of the original request URL as a string.

values_at(*keys)

like Hash#values_at

xhr?()