File: stream.rb

package info (click to toggle)
ruby-httpclient 2.8.3-3%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,672 kB
  • sloc: ruby: 9,462; makefile: 8; sh: 2
file content (21 lines) | stat: -rw-r--r-- 325 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$:.unshift(File.join('..', 'lib'))
require "httpclient"

c = HTTPClient.new

piper, pipew = IO.pipe
conn = c.post_async("http://localhost:8080/stream", piper)

Thread.new do
  res = conn.pop
  while str = res.content.read(10)
    p str
  end
end

p "type here"
while line = STDIN.gets
  pipew << line
end
pipew.close
sleep 5