summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 c33628ee29..0b07a00adf 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 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)