1 # must be run without Rack::Lint since that clobbers to_path
2 class MyMiddleware < Struct.new(:app)
3 class Body < Struct.new(:body, :to_path)
4 def each(&block); body.each(&block); end
6 c = body.respond_to?(:close)
7 ::File.open(ENV['fifo'], 'wb') do |fp|
8 fp.syswrite("CLOSING #{body.inspect} #{to_path} (#{c})\n")
15 status, headers, body = app.call(env)
16 body.respond_to?(:to_path) and body = Body.new(body, body.to_path)
17 [ status, headers, body ]
21 use Rainbows::DevFdResponse
23 io = IO.popen('cat random_blob', 'rb')
26 'Content-Length' => ::File.stat('random_blob').size.to_s,
27 'Content-Type' => 'application/octet-stream',