Class Merb::Request
In: lib/merb-core/dispatch/request.rb
Parent: Object

Methods

Constants

METHODS = %w{get post put delete head}
NAME_REGEX = /Content-Disposition:.* name="?([^\";]*)"?/ni.freeze
CONTENT_TYPE_REGEX = /Content-Type: (.*)\r\n/ni.freeze
FILENAME_REGEX = /Content-Disposition:.* filename="?([^\";]*)"?/ni.freeze
CRLF = "\r\n".freeze
EOL = CRLF

Attributes

env  [RW]  def env def session def route_params
route_params  [RW]  def env def session def route_params
session  [RW]  def env def session def route_params

Public Class methods

Parameters

s<String>:String to URL escape.

returns

String:The escaped string.

Initial the request object.

Parameters

http_request<~params:~[], ~body:IO>:An object like an HTTP Request.

Converts a query string snippet to a hash and adds it to existing parameters.

Parameters

parms<Hash>:Parameters to add the normalized parameters to.
name<String>:The key of the parameter to normalize.
val<String>:The value of the parameter.

Returns

Hash:Normalized parameters

Parameters

value<Array, Hash, ~to_s>:The value for the query string.
prefix<~to_s>:The prefix to add to the query string keys.

Returns

String:The query string.

Alternatives

If the value is a string, the prefix will be used as the key.

Examples

  params_to_query_string(10, "page")
    # => "page=10"
  params_to_query_string({ :page => 10, :word => "ruby" })
    # => "page=10&word=ruby"
  params_to_query_string({ :page => 10, :word => "ruby" }, "search")
    # => "search[page]=10&search[word]=ruby"
  params_to_query_string([ "ice-cream", "cake" ], "shopping_list")
    # => "shopping_list[]=ice-cream&shopping_list[]=cake"

Parameters

request<IO>:The raw request.
boundary<String>:The boundary string.
content_length<Fixnum>:The length of the content.

Raises

ControllerExceptions::MultiPartParseError:Failed to parse request.

Returns

Hash:The parsed request.

Parameters

qs<String>:The query string.
d<String>:The query string divider. Defaults to "&".

Returns

Mash:The parsed query string.

Examples

  query_parse("bar=nik&post[body]=heya")
    # => { :bar => "nik", :post => { :body => "heya" } }

Parameter

s<String>:String to URL unescape.

returns

String:The unescaped string.

Public Instance methods

Returns

String:The accepted response types. Defaults to "*/*".

Returns

String:The accepted character sets.

Returns

String:The accepted encodings.

Returns

String:The accepted language.
ajax?()

Alias for xml_http_request?

Returns

String:HTTP cache control.

Returns

String:The HTTP connection.

Returns

Fixnum:The request content length.

Returns

String:The request content type.

Returns

Hash:The cookies for this request.

Parameters

tld_length<Fixnum>:Number of domains levels to inlclude in the top level domain. Defaults to 1.

Returns

String:The full domain name without the port number.

Returns

String:The full hostname including the port.

Returns

String:Value of HTTP_KEEP_ALIVE.

Returns

Symbol:The name of the request method, e.g. :get.

Notes

If the method is post, then the _method param will be checked for masquerading method.

Returns

Hash:All request parameters.

Notes

The order of precedence for the params is XML, JSON, multipart, body and request string.

Returns

String:The URI without the query string. Strips trailing "/" and reduces duplicate "/" to a single "/".

Returns

String:The path info.

Returns

Fixnum:The server port.

Returns

String:The protocol, i.e. either "https://" or "http://" depending on the HTTPS header.

Returns

String:The query string.

Returns

String:The raw post.

Returns

String:The HTTP referer.

Returns

String:The remote IP address.

Resets the params to a nil value.

Returns

String:The script name.

Returns

String:The server name.

Returns

String:The server software.

Returns

Boolean::True if the request is an SSL request.

Parameters

tld_length<Fixnum>:Number of domains levels to inlclude in the top level domain. Defaults to 1.

Returns

Array:All the subdomain parts of the host.

Returns

String:The request URI.

Returns

String:The HTTP user agent.

Returns

String:The HTTP version
xhr?()

Alias for xml_http_request?

Returns

Boolean:If the request is an XML HTTP request.

[Validate]