diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-07 21:50:34 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-07 21:50:34 +0000 |
commit | 56206ab8cd0e822e861ae963fc02e2343652d8e2 (patch) | |
tree | abf1c211dddd47e6b61488497a0424ae0ce354d9 /lib | |
parent | 42109a02f02b5e55a45df4f6bf3103c88be340cd (diff) |
* lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):
use readpartial to get data even if the response is streaming data and
each data is smaller than @buffer_size.
patched by yu nobuoka. [ruby-dev:45471] [Bug #6230]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/webrick/httpresponse.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb index baa49dea92..5adbc82173 100644 --- a/lib/webrick/httpresponse.rb +++ b/lib/webrick/httpresponse.rb @@ -330,13 +330,18 @@ module WEBrick if @request_method == "HEAD" # do nothing elsif chunked? - while buf = @body.read(@buffer_size) - next if buf.empty? - data = "" - data << format("%x", buf.bytesize) << CRLF - data << buf << CRLF - _write_data(socket, data) - @sent_size += buf.bytesize + begin + buf = '' + data = '' + while true + @body.readpartial( @buffer_size, buf ) # there is no need to clear buf? + data << format("%x", buf.bytesize) << CRLF + data << buf << CRLF + _write_data(socket, data) + data.clear + @sent_size += buf.bytesize + end + rescue EOFError # do nothing end _write_data(socket, "0#{CRLF}#{CRLF}") else |