Sha256: 5b8ff15d58a4aecb65e3ea6449141d1e14b00512934c2481a62729a90b5d1c1f
Contents?: true
Size: 754 Bytes
Versions: 3
Compression:
Stored size: 754 Bytes
Contents
require 'nitro/render' module Nitro module Render # Enable streaming mode for the current # HTTP Response. # You can optionally provide an existing IO # object for streaming. #-- # This code is considered a hack fix. # But it still is useful so for the moment # it stays in the distribution. #++ def stream(io = nil) if io # Reuse an existing IO if it exists. @context.out = io else r, w = IO.pipe @context.out = r @out = w r.sync = true w.class.send(:define_method, :empty?) { false } Thread.new do begin yield rescue Object => ex p ex ensure w.close end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.24.0 | lib/nitro/cgi/stream.rb |
nitro-0.25.0 | lib/nitro/cgi/stream.rb |
nitro-0.26.0 | lib/nitro/cgi/stream.rb |