Results for: "uri"

setter for to v

setter for headers v

Synopsis

URI::Parser.new([opts])

Args

The constructor accepts a hash as options for parser. Keys of options are pattern names of URI components and values of options are pattern strings. The constructor generates set of regexps for parsing URIs.

You can use the following keys:

* :ESCAPED (URI::PATTERN::ESCAPED in default)
* :UNRESERVED (URI::PATTERN::UNRESERVED in default)
* :DOMLABEL (URI::PATTERN::DOMLABEL in default)
* :TOPLABEL (URI::PATTERN::TOPLABEL in default)
* :HOSTNAME (URI::PATTERN::HOSTNAME in default)

Examples

p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP:0xb78cf4f8 URL:http://example.jp/%uABCD>
URI.parse(u.to_s) #=> raises URI::InvalidURIError

s = "http://example.com/ABCD"
u1 = p.parse(s) #=> #<URI::HTTP:0xb78c3220 URL:http://example.com/ABCD>
u2 = URI.parse(s) #=> #<URI::HTTP:0xb78b6d54 URL:http://example.com/ABCD>
u1 == u2 #=> true
u1.eql?(u2) #=> false

Returns a split URI against regexp

Args

uri

String

Description

parses uri and constructs either matching URI scheme object (FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or URI::Generic

Usage

p = URI::Parser.new
p.parse("ldap://ldap.example.com/dc=example?user=john")
#=> #<URI::LDAP:0x00000000b9e7e8 URL:ldap://ldap.example.com/dc=example?user=john>

Args

uris

an Array of Strings

Description

Attempts to parse and merge a set of URIs

Args

str

String to search

schemes

Patterns to apply to str

Description

Attempts to parse and merge a set of URIs If no block given , then returns the result, else it calls block for each element in result.

see also URI::Parser.make_regexp

Args

str

String to make safe

unsafe

Regexp to apply. Defaults to self.regexp

Description

constructs a safe String from str, removing unsafe characters, replacing them with codes.

Args

str

String to remove escapes from

unsafe

Regexp to apply. Defaults to self.regexp

Description

Removes escapes from str

No documentation available

Synopsis

URI.escape(str [, unsafe])

Args

str

String to replaces in.

unsafe

Regexp that matches all symbols that must be replaced with codes. By default uses UNSAFE. When this argument is a String, it represents a character set.

Description

Escapes the string, replacing all unsafe characters with codes.

This method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.

Usage

require 'uri'

enc_uri = URI.escape("http://example.com/?a=\11\15")
p enc_uri
# => "http://example.com/?a=%09%0D"

p URI.unescape(enc_uri)
# => "http://example.com/?a=\t\r"

p URI.escape("@?@!", "!?")
# => "@%3F@%21"
No documentation available

Synopsis

URI.unescape(str)

Args

str

Unescapes the string.

Usage

require 'uri'

enc_uri = URI.escape("http://example.com/?a=\11\15")
p enc_uri
# => "http://example.com/?a=%09%0D"

p URI.unescape(enc_uri)
# => "http://example.com/?a=\t\r"
No documentation available

Thanks, FakeWeb!

No documentation available

The UriFormatter handles URIs from user-input and escaping.

uf = Gem::UriFormatter.new 'example.com'

p uf.normalize #=> 'http://example.com'

Generate URL-encoded form data from given enum.

This generates application/x-www-form-urlencoded data defined in HTML5 from given an Enumerable object.

This internally uses URI.encode_www_form_component(str).

This method doesn’t convert the encoding of given items, so convert them before call this method if you want to send data as other than original encoding or mixed encoding data. (Strings which are encoded in an HTML5 ASCII incompatible encoding are converted to UTF-8.)

This method doesn’t handle files. When you send a file, use multipart/form-data.

This refers url.spec.whatwg.org/#concept-urlencoded-serializer

URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
#=> "q=ruby&lang=en"
URI.encode_www_form("q" => "ruby", "lang" => "en")
#=> "q=ruby&lang=en"
URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
#=> "q=ruby&q=perl&lang=en"
URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
#=> "q=ruby&q=perl&lang=en"

See URI.encode_www_form_component, URI.decode_www_form

Decode URL-encoded form data from given str.

This decodes application/x-www-form-urlencoded data and returns array of key-value array.

This refers url.spec.whatwg.org/#concept-urlencoded-parser , so this supports only &-separator, don’t support ;-separator.

ary = URI.decode_www_form("a=1&a=2&b=3")
p ary                  #=> [['a', '1'], ['a', '2'], ['b', '3']]
p ary.assoc('a').last  #=> '1'
p ary.assoc('b').last  #=> '3'
p ary.rassoc('a').last #=> '2'
p Hash[ary]            # => {"a"=>"2", "b"=>"3"}

See URI.decode_www_form_component, URI.encode_www_form

No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
Search took: 3ms  ·  Total Results: 1036