Returns the full path for a WS
URI
, as required by Net::HTTP::Get
.
If the URI
contains a query, the full path is URI#path + ‘?’ + URI#query. Otherwise, the path is simply URI#path.
Example:
uri = URI::WS.build(path: '/foo/bar', query: 'test=true') uri.request_uri # => "/foo/bar?test=true"
Returns a URI object derived from the given uri
, which may be a URI string or an existing URI object:
# Returns a new URI. uri = URI('http://github.com/ruby/ruby') # => #<URI::HTTP http://github.com/ruby/ruby> # Returns the given URI. URI(uri) # => #<URI::HTTP http://github.com/ruby/ruby>
Returns a URI object derived from the given uri
, which may be a URI string or an existing URI object:
# Returns a new URI. uri = URI('http://github.com/ruby/ruby') # => #<URI::HTTP http://github.com/ruby/ruby> # Returns the given URI. URI(uri) # => #<URI::HTTP http://github.com/ruby/ruby>
Allows the opening of various resources including URIs.
If the first argument responds to the ‘open’ method, ‘open’ is called on it with the rest of the arguments.
If the first argument is a string that begins with (protocol)://
, it is parsed by URI.parse
. If the parsed object responds to the ‘open’ method, ‘open’ is called on it with the rest of the arguments.
Otherwise, Kernel#open
is called.
OpenURI::OpenRead#open
provides URI::HTTP#open
, URI::HTTPS#open
and URI::FTP#open
, Kernel#open
.
We can accept URIs and strings that begin with http://, https:// and ftp://. In these cases, the opened file object is extended by OpenURI::Meta
.
Returns a new object constructed from the given scheme
, arguments
, and default
:
The new object is an instance of URI.scheme_list[scheme.upcase]
.
The object is initialized by calling the class initializer using scheme
and arguments
. See URI::Generic.new
.
Examples:
values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top'] URI.for('https', *values) # => #<URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top> URI.for('foo', *values, default: URI::HTTP) # => #<URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
Returns a 9-element array representing the parts of the URI formed from the string uri
; each array element is a string or nil
:
names = %w[scheme userinfo host port registry path opaque query fragment] values = URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') names.zip(values) # => [["scheme", "https"], ["userinfo", "john.doe"], ["host", "www.example.com"], ["port", "123"], ["registry", nil], ["path", "/forum/questions/"], ["opaque", nil], ["query", "tag=networking&order=newest"], ["fragment", "top"]]
Returns a new URI object constructed from the given string uri
:
URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') # => #<URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top> URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') # => #<URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
It’s recommended to first ::escape string uri
if it may contain invalid URI
characters.
Merges the given URI
strings str
per RFC 2396.
Each string in str
is converted to an RFC3986 URI before being merged.
Examples:
URI.join("http://example.com/","main.rbx") # => #<URI::HTTP http://example.com/main.rbx> URI.join('http://example.com', 'foo') # => #<URI::HTTP http://example.com/foo> URI.join('http://example.com', '/foo', '/bar') # => #<URI::HTTP http://example.com/bar> URI.join('http://example.com', '/foo', 'bar') # => #<URI::HTTP http://example.com/bar> URI.join('http://example.com', '/foo/', 'bar') # => #<URI::HTTP http://example.com/foo/bar>
Returns the authority for an HTTP
uri, as defined in www.rfc-editor.org/rfc/rfc3986#section-3.2.
Example:
URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com" URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000" URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"
Returns the origin for an HTTP
uri, as defined in www.rfc-editor.org/rfc/rfc6454.
Example:
URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com" URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000" URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com" URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
Sets userinfo, argument is string like ‘name:pass’.
Returns the userinfo, either as ‘user’ or ‘user:password’.
Returns attributes.
Setter for attributes val
.
do nothing
Checks the user
and password
.
If password
is not provided, then user
is split, using URI::Generic.split_userinfo
, to pull user
and +password.
See also URI::Generic.check_user
, URI::Generic.check_password
.
Protected setter for the user
component, and password
if available (with validation).
See also URI::Generic.userinfo=
.
Returns the userinfo ui
as [user, password]
if properly formatted as ‘user:password’.
Private setter for attributes val
.
we have our own signing code here to avoid a dependency on the aws-sdk gem