Class: HTTPalooza::Players::TelnetPlayer
- Defined in:
- lib/httpalooza/players/telnet.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
execute!, #initialize, introducing!, #name
Constructor Details
This class inherits a constructor from HTTPalooza::Players::Base
Instance Method Details
#response ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/httpalooza/players/telnet.rb', line 9 def response uri = URI::parse(request.url) raise "Unsupported scheme: #{uri.scheme}" unless uri.scheme.to_s.upcase == 'HTTP' Open3.popen3('telnet', uri.host, uri.port.to_s) do |stdin, stdout, stderr, wait_thr| begin while !stdout.readline.start_with?('Escape character is'); end stdin.write(request_text(uri)) stdin.flush code = stdout.readline.match(/HTTP\S* (\d+)/)[1].to_i while !stdout.readline.strip.empty?; end body = stdout.read Response.new(code, body) rescue Process.kill("TERM", wait_thr.pid) rescue Errno::ESRCH raise end end end |