be sure to close the body. also add a config for benchmarking

This commit is contained in:
John Bintz 2012-08-29 13:33:50 -04:00
parent f8ebf9fbb1
commit 81a049fc71
3 changed files with 31 additions and 1 deletions

28
config.ru Normal file
View File

@ -0,0 +1,28 @@
$: << File.expand_path('../lib', __FILE__)
require 'rack-emstream'
class Sender
def initialize
@times = 100
@data = "data"
end
def each
@times.times { |i|
yield @data
}
end
def length
@times * @data.length
end
end
require 'logger'
use Rack::EMStream
run lambda { |env|
sender = Sender.new
[ 200, { 'Content-Length' => sender.length.to_s }, sender ]
}

View File

@ -22,6 +22,8 @@ module Rack
EM.next_tick {
env['async.callback'].call [ result[0], result[1], self ]
result[2].close if result[2].respond_to?(:close)
result[2].each { |data| EM.next_tick { @callback.call(data) } }
EM.next_tick { succeed }
}

View File

@ -1,5 +1,5 @@
module Rack
class EMStream
VERSION = "0.1.0"
VERSION = "0.1.1"
end
end