Merge pull request #33 from ssendev/image-passthru

pass images through
This commit is contained in:
John Bintz 2013-04-21 08:59:55 -07:00
commit 2eae7fd1bb
2 changed files with 18 additions and 2 deletions

View File

@ -59,7 +59,8 @@ module Rack
else else
status, headers, body = result = @app.call(env) 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['Transfer-Encoding'] == 'chunked' or
headers['Content-Disposition'] =~ %r{^inline} headers['Content-Disposition'] =~ %r{^inline}
return result return result

View File

@ -53,7 +53,7 @@ describe Rack::LiveReload do
end end
context 'not text/html' do context 'not text/html' do
let(:ret) { [ 200, { 'Content-Type' => 'image/png' }, [ '<head></head>' ] ] } let(:ret) { [ 200, { 'Content-Type' => 'application/pdf' }, [ '<head></head>' ] ] }
before do before do
app.stubs(:call).with(env).returns(ret) app.stubs(:call).with(env).returns(ret)
@ -64,6 +64,21 @@ describe Rack::LiveReload do
end end
end end
context 'image/png' do
let(:body) { [ '<head></head>' ] }
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 context 'text/event-stram' do
let(:body) { [ '<head></head>' ] } let(:body) { [ '<head></head>' ] }
let(:ret) { [ 200, { 'Content-Type' => 'text/event-stream' }, body ] } let(:ret) { [ 200, { 'Content-Type' => 'text/event-stream' }, body ] }