diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-21 10:10:52 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-21 10:10:52 +0000 |
commit | b8f68de2be55082cb7b7478d7fa1f5a34db0dd06 (patch) | |
tree | 0318193bbd7e617bcdc7a8fc3b0f6d996a3d929a /lib/webrick/httpresponse.rb | |
parent | 2870c4d1a65e17e05fead85d526765306f44ac93 (diff) |
* lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):
ensure to close @body. (http://bugs.debian.org/277520)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpresponse.rb')
-rw-r--r-- | lib/webrick/httpresponse.rb | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb index 717329fef3..d0f232d1e1 100644 --- a/lib/webrick/httpresponse.rb +++ b/lib/webrick/httpresponse.rb @@ -254,24 +254,27 @@ module WEBrick private def send_body_io(socket) - if @request_method == "HEAD" - # do nothing - elsif chunked? - while buf = @body.read(BUFSIZE) - next if buf.empty? - data = "" - data << format("%x", buf.size) << CRLF - data << buf << CRLF - _write_data(socket, data) - @sent_size += buf.size + begin + if @request_method == "HEAD" + # do nothing + elsif chunked? + while buf = @body.read(BUFSIZE) + next if buf.empty? + data = "" + data << format("%x", buf.size) << CRLF + data << buf << CRLF + _write_data(socket, data) + @sent_size += buf.size + end + _write_data(socket, "0#{CRLF}#{CRLF}") + else + size = @header['content-length'].to_i + _send_file(socket, @body, 0, size) + @sent_size = size end - _write_data(socket, "0#{CRLF}#{CRLF}") - else - size = @header['content-length'].to_i - _send_file(socket, @body, 0, size) - @sent_size = size + ensure + @body.close end - @body.close end def send_body_string(socket) |