Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 33 lines (28 sloc) 0.66 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
$LOAD_PATH.unshift 'lib'
require 'rack/async_stream'

app = proc do
  body = Object.new
  def body.each
    10.times do |i|
      yield "Number #{i}\n"
      sleep 0.3
    end
  end
  [200, {'Content-Type' => 'text/plain'}, body]
end

map '/fiber' do
  use Rack::AsyncStream, :logging => true, :stream => Rack::AsyncStream::FiberStream
  run app
end

map '/callcc' do
  use Rack::AsyncStream, :logging => true, :stream => Rack::AsyncStream::ContinuationStream
  run app
end

map '/thread' do
  use Rack::AsyncStream, :logging => true, :stream => Rack::AsyncStream::ThreadStream
  run app
end

map '/' do
  use Rack::AsyncStream, :logging => true
  run app
end
Something went wrong with that request. Please try again.