Public Instance methods
request(*args, **options)
[show source]
# File lib/httpx/plugins/proxy/ssh.rb 22 def request(*args, **options) 23 raise ArgumentError, "must perform at least one request" if args.empty? 24 25 requests = args.first.is_a?(Request) ? args : build_requests(*args, options) 26 27 request = requests.first or return super 28 29 request_options = request.options 30 31 return super unless request_options.proxy 32 33 ssh_options = request_options.proxy 34 ssh_uris = ssh_options.delete(:uri) 35 ssh_uri = URI.parse(ssh_uris.shift) 36 37 return super unless ssh_uri.scheme == "ssh" 38 39 ssh_username = ssh_options.delete(:username) 40 ssh_options[:port] ||= ssh_uri.port || 22 41 if request_options.debug 42 ssh_options[:verbose] = request_options.debug_level == 2 ? :debug : :info 43 end 44 45 request_uri = URI(requests.first.uri) 46 @_gateway = Net::SSH::Gateway.new(ssh_uri.host, ssh_username, ssh_options) 47 begin 48 @_gateway.open(request_uri.host, request_uri.port) do |local_port| 49 io = build_gateway_socket(local_port, request_uri, request_options) 50 super(*args, **options.merge(io: io)) 51 end 52 ensure 53 @_gateway.shutdown! 54 end 55 end