Module Merb::Parse
In: lib/merb-core/dispatch/request_parsers.rb

Methods

Constants

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

Public Class methods

Parameters

s<String>:String to URL escape.

returns

String:The escaped string.

:api: public

Parameters

s<String>:String to XML escape.

returns

String:The escaped string.

:api: public

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.

:api: plugin

Parameters

value<Array, Hash, Dictionary ~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"

:api: plugin

Parameters

query_string<String>:The query string.
delimiter<String>:The query string divider. Defaults to "&".
preserve_order<Boolean>:Preserve order of args. Defaults to false.

Returns

Mash:The parsed query string (Dictionary if preserve_order is set).

Examples

  Merb::Parse.query("bar=nik&post[body]=heya")
    # => { :bar => "nik", :post => { :body => "heya" } }

:api: plugin

Parameter

s<String>:String to URL unescape.
encoding<String>:Encoding which we force to return. Only for Ruby 1.9. If encoding is not passed it defaults to Encoding.default_internal. When this is nil (default) no encoding forcing is done.

returns

String:The unescaped string.

:api: public

[Validate]