summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-21 10:10:52 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-21 10:10:52 +0000
commit9a11d5e1473e44590e38986fcc94ad015c6144ba (patch)
tree596310d916516dcd079b66deb3f3a265c3a80ddc
parentf71b2a1e2b0c272bcf2f1bae29ea9964d2f7201d (diff)
downloadruby-9a11d5e1473e44590e38986fcc94ad015c6144ba.tar.gz
ruby-9a11d5e1473e44590e38986fcc94ad015c6144ba.tar.xz
ruby-9a11d5e1473e44590e38986fcc94ad015c6144ba.zip
* lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):
ensure to close @body. (http://bugs.debian.org/277520) git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/webrick/httpresponse.rb35
2 files changed, 24 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index c33628ee2..0b07a00ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Oct 21 19:06:15 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):
+ ensure to close @body. (http://bugs.debian.org/277520)
+
Wed Oct 20 19:45:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): reentrant check. [ruby-dev:24432]
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 717329fef..d0f232d1e 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)