Merge pull request #30 from pdf/dont_mess_with_chunk_endcoded
Don't force iterating chunked (streamed) responses
This commit is contained in:
commit
306e5cd275
|
@ -59,7 +59,11 @@ module Rack
|
||||||
else
|
else
|
||||||
status, headers, body = result = @app.call(env)
|
status, headers, body = result = @app.call(env)
|
||||||
|
|
||||||
return result if headers['Content-Type'] and headers['Content-Type']['text/event-stream']
|
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
|
||||||
|
|
||||||
body.close if body.respond_to?(:close)
|
body.close if body.respond_to?(:close)
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,36 @@ describe Rack::LiveReload do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'chunked response' do
|
||||||
|
let(:body) { [ '<head></head>' ] }
|
||||||
|
let(:ret) { [ 200, { 'Transfer-Encoding' => 'chunked' }, 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 'inline disposition' do
|
||||||
|
let(:body) { [ '<head></head>' ] }
|
||||||
|
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
|
context 'unknown Content-Type' do
|
||||||
let(:ret) { [ 200, {}, [ 'hey ho' ] ] }
|
let(:ret) { [ 200, {}, [ 'hey ho' ] ] }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue