oth
URI
or String
Calculates relative path from oth to self
require 'uri' uri = URI.parse('http://my.example.com/main.rbx?page=1') p uri.route_from('http://my.example.com') #=> #<URI::Generic:0x20218858 URL:/main.rbx?page=1>
oth
URI
or String
Calculates relative path to oth from self
require 'uri' uri = URI.parse('http://my.example.com') p uri.route_to('http://my.example.com/main.rbx?page=1') #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1>
Constructs String from URI
returns an Array of the components defined from the COMPONENT
Array
returns a proxy URI
. The proxy URI
is obtained from environment variables such as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper proxy, nil is returned.
Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are examined too.
But http_proxy and HTTP_PROXY is treated specially under CGI
environment. It’s because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY can be used instead.
private method to cleanup dn
from using the path
component attribute
private method to cleanup attributes
, scope
, filter
and extensions
, from using the query
component attribute
private setter for dn val
private setter for scope val
private setter for filter val
private setter for extensions val
check the to v
component
private setter for to v
private setter for headers v
Constructs String from URI
Returns the RFC822 e-mail text equivalent of the URL, as a String.
Example:
require 'uri' uri = URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr") uri.to_mailtext # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
URI::Parser.new([opts])
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)
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
uri
String
parses uri
and constructs either matching URI
scheme object (FTP
, HTTP
, HTTPS
, LDAP
, LDAPS
, or MailTo
) or URI::Generic
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>
uris
an Array of Strings
Attempts to parse and merge a set of URIs
str
String to search
schemes
Patterns to apply to str
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
str
String to make safe
unsafe
Regexp
to apply. Defaults to self.regexp
constructs a safe String from str
, removing unsafe characters, replacing them with codes.
str
String to remove escapes from
unsafe
Regexp
to apply. Defaults to self.regexp
Removes escapes from str