diff --git a/lib/rack/livereload.rb b/lib/rack/livereload.rb index 349640d..8f2fb43 100644 --- a/lib/rack/livereload.rb +++ b/lib/rack/livereload.rb @@ -59,7 +59,8 @@ module Rack else status, headers, body = result = @app.call(env) - if (headers['Content-Type'] and headers['Content-Type']['text/event-stream']) or + if (headers['Content-Type'] and (headers['Content-Type']['text/event-stream'] or + headers['Content-Type'][%r{^image/}])) or headers['Transfer-Encoding'] == 'chunked' or headers['Content-Disposition'] =~ %r{^inline} return result diff --git a/spec/rack/livereload_spec.rb b/spec/rack/livereload_spec.rb index bdcdac9..40fabb2 100644 --- a/spec/rack/livereload_spec.rb +++ b/spec/rack/livereload_spec.rb @@ -53,7 +53,7 @@ describe Rack::LiveReload do end context 'not text/html' do - let(:ret) { [ 200, { 'Content-Type' => 'image/png' }, [ '' ] ] } + let(:ret) { [ 200, { 'Content-Type' => 'application/pdf' }, [ '' ] ] } before do app.stubs(:call).with(env).returns(ret) @@ -64,6 +64,21 @@ describe Rack::LiveReload do end end + context 'image/png' do + let(:body) { [ '' ] } + let(:ret) { [ 200, { 'Content-Type' => 'image/png' }, 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 'text/event-stram' do let(:body) { [ '' ] } let(:ret) { [ 200, { 'Content-Type' => 'text/event-stream' }, body ] }