mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Merge pull request #535 from yeban/stream_closed
add closed? method on Stream object to inspect the object's open/close state
This commit is contained in:
commit
d2e8563f8b
2 changed files with 11 additions and 0 deletions
|
@ -332,6 +332,10 @@ module Sinatra
|
|||
end
|
||||
|
||||
alias errback callback
|
||||
|
||||
def closed?
|
||||
@closed
|
||||
end
|
||||
end
|
||||
|
||||
# Allows to start sending data to the client even though later parts of
|
||||
|
|
|
@ -139,4 +139,11 @@ class StreamingTest < Test::Unit::TestCase
|
|||
get '/'
|
||||
assert ran
|
||||
end
|
||||
|
||||
it 'has a public interface to inspect its open/closed state' do
|
||||
stream = Stream.new(Stream) { |out| out << :foo }
|
||||
assert !stream.closed?
|
||||
stream.close
|
||||
assert stream.closed?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue