Method: Bio::Command.new_http
- Defined in:
- lib/bio/command.rb
.new_http(address, port = 80) ⇒ Object
Same as:
Net::HTTP.new(address, port)
and it uses proxy if an environment variable (same as OpenURI.open_uri) is set.
Arguments:
-
(required) address: String containing host name or IP address
-
(optional) port: port (sanme as Net::HTTP::start)
- Returns
-
(same as Net::HTTP.new except for proxy support)
451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/bio/command.rb', line 451 def new_http(address, port = 80) uri = URI.parse("http://#{address}:#{port}") # Note: URI#find_proxy is an unofficial method defined in open-uri.rb. # If the spec of open-uri.rb would be changed, we should change below. if proxyuri = uri.find_proxy then raise 'Non-HTTP proxy' if proxyuri.class != URI::HTTP Net::HTTP.new(address, port, proxyuri.host, proxyuri.port) else Net::HTTP.new(address, port) end end |