class Excon::Connection

def proxy_from_env

def proxy_from_env
  if (no_proxy_env = ENV['no_proxy'] || ENV['NO_PROXY'])
    no_proxy_list = no_proxy_env.scan(/\s*(?:\[([\dA-Fa-f:\/]+)\]|\*?\.?([^\s,:]+))(?::(\d+))?\s*/i).map { |e|
      if e[0]
        begin
          [IPAddr.new(e[0]), e[2]]
        rescue IPAddr::Error
          nil
        end
      else
        begin
          [IPAddr.new(e[1]), e[2]]
        rescue IPAddr::Error
          [e[1], e[2]]
        end
      end
    }.reject { |e| e.nil? || e[0].nil? }
  end
  unless no_proxy_env && no_proxy_list.index { |h| proxy_match_host_port(h[0], h[1]) }
    if @data[:scheme] == HTTPS && (ENV.has_key?('https_proxy') || ENV.has_key?('HTTPS_PROXY'))
      @data[:proxy] = ENV['https_proxy'] || ENV['HTTPS_PROXY']
    elsif (ENV.has_key?('http_proxy') || ENV.has_key?('HTTP_PROXY'))
      @data[:proxy] = ENV['http_proxy'] || ENV['HTTP_PROXY']
    end
  end
end