From 6b93954231663be8ed3d1262b8458606ccdffca0 Mon Sep 17 00:00:00 2001 From: Peter Fern Date: Tue, 19 Mar 2013 17:32:46 +1100 Subject: [PATCH] While we're at not messing with stuff, don't mess with inlined content --- lib/rack/livereload.rb | 4 +++- spec/rack/livereload_spec.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/rack/livereload.rb b/lib/rack/livereload.rb index c693d24..0a7b613 100644 --- a/lib/rack/livereload.rb +++ b/lib/rack/livereload.rb @@ -59,7 +59,9 @@ module Rack else status, headers, body = result = @app.call(env) - if (headers['Content-Type'] and headers['Content-Type']['text/event-stream']) or headers['Transfer-Encoding'] == 'chunked' + if (headers['Content-Type'] and headers['Content-Type']['text/event-stream']) or + headers['Transfer-Encoding'] == 'chunked' or + headers['Content-Disposition'] =~ %r{^inline} return result end diff --git a/spec/rack/livereload_spec.rb b/spec/rack/livereload_spec.rb index b1488d6..928645f 100644 --- a/spec/rack/livereload_spec.rb +++ b/spec/rack/livereload_spec.rb @@ -94,6 +94,21 @@ describe Rack::LiveReload do end end + context 'inline disposition' do + let(:body) { [ '' ] } + let(:ret) { [ 200, { 'Content-Disposition' => 'inline; filename=my_inlined_file' }, 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' ] ] }