Method: Excon.new
- Defined in:
- lib/excon.rb
.new(url, params = {}) ⇒ Object
Initializes a new keep-alive session for a given remote host
@param [String] url The destination URL
@param [Hash<Symbol, >] params One or more option params to set on the Connection instance
@return [Connection] A new Excon::Connection instance
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/excon.rb', line 135 def new(url, params = {}) uri_parser = params[:uri_parser] || Excon.defaults[:uri_parser] uri = uri_parser.parse(url) raise ArgumentError.new("Invalid URI: #{uri}") unless uri.scheme params = { :host => uri.host, :path => uri.path, :port => uri.port, :query => uri.query, :scheme => uri.scheme, :user => (Utils.unescape_uri(uri.user) if uri.user), :password => (Utils.unescape_uri(uri.password) if uri.password) }.merge!(params) Excon::Connection.new(params) end |