Don't force iterating chunked (streamed) responses #30

Merged
pdf merged 2 commits from dont_mess_with_chunk_endcoded into master 2013-03-19 13:31:40 +00:00
2 changed files with 18 additions and 1 deletions
Showing only changes of commit 75c50f7e92 - Show all commits

View File

@ -59,7 +59,9 @@ module Rack
else
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'
return result
end
body.close if body.respond_to?(:close)

View File

@ -79,6 +79,21 @@ describe Rack::LiveReload do
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 'unknown Content-Type' do
let(:ret) { [ 200, {}, [ 'hey ho' ] ] }