diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-08-11 18:46:33 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-08-11 18:46:33 +0000 |
commit | d5b23a5a61568e51ca89adfc86d0f42fd27cee5d (patch) | |
tree | 0b51becbd357b824d92ad10645d84254fddc79e4 /lib/mongrel.rb | |
parent | ee675d5a703efaab60ef90a8b41f87348d928db7 (diff) | |
download | unicorn-d5b23a5a61568e51ca89adfc86d0f42fd27cee5d.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@312 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'lib/mongrel.rb')
-rw-r--r-- | lib/mongrel.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/mongrel.rb b/lib/mongrel.rb index a4ca700..7349dae 100644 --- a/lib/mongrel.rb +++ b/lib/mongrel.rb @@ -194,7 +194,8 @@ module Mongrel dispatcher.request_begins(params) if dispatcher - if remain == 0 + # Some clients (like FF1.0) report 0 for body and then send a body. This will probably truncate them but at least the request goes through usually. + if remain <= 0 # we've got everything, pack it up @body = StringIO.new @body.write params.http_body @@ -416,17 +417,18 @@ module Mongrel end # Appends the contents of +path+ to the response stream. The file is opened for binary - # reading and written in chunks to the socket. If the - # <a href="http://rubyforge.org/projects/ruby-sendfile">sendfile</a> library is found, - # it is used to send the file, often with greater speed and less memory/cpu usage. + # reading and written in chunks to the socket. # - # The presence of ruby-sendfile is determined by @socket.response_to? :sendfile, which means - # that if you have your own sendfile implementation you can use it without changing this function, - # just make sure it follows the ruby-sendfile signature. + # Sendfile API support has been removed in 0.3.13.4 due to stability problems. def send_file(path) File.open(path, "rb") do |f| while chunk = f.read(Const::CHUNK_SIZE) and chunk.length > 0 - write(chunk) + begin + write(chunk) + rescue Object => exc + # TODO: find out if people care about failures to write these files + break + end end @body_sent = true end |