title: Streaming on Ruby Thin server
body: <p>I tried the following ruby code...</p>
  
  <pre><code> self.response.headers["Cache-Control"] ||= "no-cache"
   self.response.headers["Transfer-Encoding"] = "chunked"
   self.response.headers['Last-Modified'] = Time.now.ctime.to_s
   self.response_body =  Rack::Chunked::Body.new(Enumerator.new do |y|
     10.times do
  
       sleep 1
       y &lt;&lt; "Hello World\n"
     end
   end)
  </code></pre>
  
  <p>This works great in Unicron server but can't stream using Thin server. I tried 1.5.0 and 2.0.0.pre too, this is not working in thin.</p>
  
  <p>I tried the following rack code,</p>
  
  <pre><code>class DeferredBody
    def each(block)
      @server_block = block
    end
  
    def send(data)
      @server_block.call data
    end
  end
  
  class RackStreamApp
    def self.call(env)
      Thread.new do
        sleep 2  # simulate waiting for some event
        body = DeferredBody.new
        response = [200, {'Content-Type' =&gt; 'text/plain'}, body]
        env['async.callback'].call response
  
        body.send 'Hello, '
        sleep 2
        body.send 'World'
      end
  
      [-1, {}, []]  # or throw :async
    end
  end
  </code></pre>
  
  <p>The above code streams "Hello, World" if we use Unicorn Server, but the code doesn't stream using Thin server 1.5.0 ( I tried 2.0.0-pre too)</p>
  
  <p>Is there anything I can do to stream data using the thin server?</p>