coolio+xepoll_thread*: use shutdown() for keepalive timeout
[rainbows.git] / t / close-pipe-response.ru
blob4e347660deabee889e9f05154dc50ad70b4deddc
1 # must be run without Rack::Lint since that clobbers to_path
2 class CloseWrapper < Struct.new(:to_io)
3   def each(&block)
4     to_io.each(&block)
5   end
7   def close
8     ::File.open(ENV['fifo'], 'wb') do |fp|
9       fp.syswrite("CLOSING #{to_io}\n")
10       if to_io.respond_to?(:close) && ! to_io.closed?
11         to_io.close
12       end
13     end
14   end
15 end
16 use Rainbows::DevFdResponse
17 run(lambda { |env|
18   io = IO.popen('cat random_blob', 'rb')
19   [ 200,
20     {
21       'Content-Length' => ::File.stat('random_blob').size.to_s,
22       'Content-Type' => 'application/octet-stream',
23     },
24     CloseWrapper[io] ]