ensure responses get passed through even if not running under thin
This commit is contained in:
parent
4a658a84d8
commit
fd5a05afae
@ -18,7 +18,7 @@ class FileStreamer
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# then respond with a FileStreamer
|
# then respond with a `FileStreamer`
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
# ... do stuff ...
|
# ... do stuff ...
|
||||||
@ -44,3 +44,5 @@ use Rack::EMStream do |exception, environment|
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
I'm still pretty n00b to async stuff, so if you have suggestions, let me know!
|
||||||
|
|
||||||
|
@ -21,27 +21,31 @@ module Rack
|
|||||||
|
|
||||||
result[2].close if result[2].respond_to?(:close)
|
result[2].close if result[2].respond_to?(:close)
|
||||||
|
|
||||||
EM.next_tick {
|
if env['async.callback']
|
||||||
env['async.callback'].call [ result[0], result[1], self ]
|
EM.next_tick {
|
||||||
|
env['async.callback'].call [ result[0], result[1], self ]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
result[2].each { |data|
|
result[2].each { |data|
|
||||||
EM.next_tick {
|
EM.next_tick {
|
||||||
begin
|
begin
|
||||||
@callback.call(data)
|
@callback.call(data)
|
||||||
rescue => e
|
rescue => e
|
||||||
@callback.call(@block.call(e, env)) if @block
|
@callback.call(@block.call(e, env)) if @block
|
||||||
end
|
end
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
rescue => e
|
||||||
rescue => e
|
@callback.call(@block.call(e, env)) if @block
|
||||||
@callback.call(@block.call(e, env)) if @block
|
end
|
||||||
end
|
|
||||||
|
|
||||||
EM.next_tick { succeed }
|
EM.next_tick { succeed }
|
||||||
}
|
}
|
||||||
|
|
||||||
throw :async
|
throw :async
|
||||||
|
else
|
||||||
|
result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module Rack
|
module Rack
|
||||||
class EMStream
|
class EMStream
|
||||||
VERSION = "0.1.3"
|
VERSION = "0.1.4"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user