Class: ExecJS::FastNode::ExternalPipedRuntime::VMCommand
- Inherits:
-
Object
- Object
- ExecJS::FastNode::ExternalPipedRuntime::VMCommand
- Defined in:
- lib/execjs/fastnode/external_piped_runtime.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(socket_path, cmd, arguments) ⇒ VMCommand
constructor
A new instance of VMCommand.
Constructor Details
#initialize(socket_path, cmd, arguments) ⇒ VMCommand
Returns a new instance of VMCommand.
14 15 16 17 18 |
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 14 def initialize(socket_path, cmd, arguments) @socket_path = socket_path.to_s @cmd = cmd @arguments = arguments end |
Instance Method Details
#execute ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/execjs/fastnode/external_piped_runtime.rb', line 20 def execute sock = Net::BufferedIO.new(socket) request = Net::HTTP::Post.new("/") request['Connection'] = 'close' request['Content-Type'] = 'application/json' request.body = contents request.exec(sock, "1.1", "/") begin response = Net::HTTPResponse.read_new(sock) end while response.kind_of?(Net::HTTPContinue) response.reading_body(sock, request.response_body_permitted?) { } sock.close parse(response.body) end |