don't try to close text/event-stream bodies, should fix #24
This commit is contained in:
parent
fbbea710d7
commit
85855cb25a
|
@ -1,6 +1,6 @@
|
|||
require "rack/livereload"
|
||||
|
||||
class Rack::LiveReload
|
||||
VERSION = '0.3.10'
|
||||
VERSION = '0.3.11'
|
||||
end
|
||||
|
||||
|
|
|
@ -52,7 +52,10 @@ module Rack
|
|||
if path == '__rack' && ::File.file?(target = ::File.expand_path("../../../js/#{file}", __FILE__))
|
||||
deliver_file(target)
|
||||
else
|
||||
status, headers, body = @app.call(env)
|
||||
status, headers, body = result = @app.call(env)
|
||||
|
||||
return result if headers['Content-Type'] and headers['Content-Type']['text/event-stream']
|
||||
|
||||
body.close if body.respond_to?(:close)
|
||||
|
||||
new_body = [] ; body.each { |line| new_body << line.to_s }
|
||||
|
|
|
@ -54,6 +54,21 @@ describe Rack::LiveReload do
|
|||
end
|
||||
end
|
||||
|
||||
context 'text/event-stram' do
|
||||
let(:body) { [ '<head></head>' ] }
|
||||
let(:ret) { [ 200, { 'Content-Type' => 'text/event-stream' }, body ] }
|
||||
|
||||
before do
|
||||
app.stubs(:call).with(env).returns(ret)
|
||||
body.expects(:close).never
|
||||
body.stubs(:respond_to?).with(:close).returns(true)
|
||||
end
|
||||
|
||||
it 'should pass through' do
|
||||
middleware.call(env).should == ret
|
||||
end
|
||||
end
|
||||
|
||||
context 'unknown Content-Type' do
|
||||
let(:ret) { [ 200, {}, [ 'hey ho' ] ] }
|
||||
|
||||
|
|
Loading…
Reference in New Issue