diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index deab7993..0db7de26 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -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 diff --git a/test/streaming_test.rb b/test/streaming_test.rb index df2bf7d3..71dc8db6 100644 --- a/test/streaming_test.rb +++ b/test/streaming_test.rb @@ -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