Sha256: 650f75ba38f817b60531ffb829a69d84dca6cf49511d38e036b8d8fde38b393c

Contents?: true

Size: 599 Bytes

Versions: 34

Compression:

Stored size: 599 Bytes

Contents

# must be run without Rack::Lint since that clobbers to_path
class CloseWrapper < Struct.new(:to_io)
  def each(&block)
    to_io.each(&block)
  end

  def close
    ::File.open(ENV['fifo'], 'wb') do |fp|
      fp.syswrite("CLOSING #{to_io}\n")
      if to_io.respond_to?(:close) && ! to_io.closed?
        to_io.close
      end
    end
  end
end
use Rainbows::DevFdResponse
run(lambda { |env|
  io = IO.popen('cat random_blob', 'rb')
  [ 200,
    {
      'Content-Length' => ::File.stat('random_blob').size.to_s,
      'Content-Type' => 'application/octet-stream',
    },
    CloseWrapper[io] ]
})

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
rainbows-5.2.1 t/close-pipe-response.ru
rainbows-5.2.0 t/close-pipe-response.ru
rainbows-5.1.1 t/close-pipe-response.ru
rainbows-5.1.0 t/close-pipe-response.ru
rainbows-5.0.0.5.ge717 t/close-pipe-response.ru
rainbows-5.0.0 t/close-pipe-response.ru
rainbows-4.7.0 t/close-pipe-response.ru
rainbows-4.6.2 t/close-pipe-response.ru
rainbows-4.6.1 t/close-pipe-response.ru
rainbows-4.6.0.4.g4108 t/close-pipe-response.ru
rainbows-4.6.0 t/close-pipe-response.ru
rainbows-4.5.0 t/close-pipe-response.ru
rainbows-4.4.3 t/close-pipe-response.ru
rainbows-4.4.2 t/close-pipe-response.ru
rainbows-4.4.1.1.gd5c8c t/close-pipe-response.ru
rainbows-4.4.1 t/close-pipe-response.ru
rainbows-4.4.0 t/close-pipe-response.ru
rainbows-4.3.1 t/close-pipe-response.ru
rainbows-4.3.0 t/close-pipe-response.ru
rainbows-4.2.0 t/close-pipe-response.ru