From 3e5ca782bccb6676c2950b0e84cc3eefec5e8ca1 Mon Sep 17 00:00:00 2001 From: why Date: Tue, 11 Apr 2006 00:17:19 +0000 Subject: Excuse my improprieties. Wrongful use of @response in the Camping handler. Calling send_status now. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@156 19e92222-5c0b-0410-8929-a290d50e31e9 --- lib/mongrel/camping.rb | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/mongrel/camping.rb b/lib/mongrel/camping.rb index fb4efb8..5e42c9f 100644 --- a/lib/mongrel/camping.rb +++ b/lib/mongrel/camping.rb @@ -34,31 +34,33 @@ module Mongrel def process(request, response) req = StringIO.new(request.body) controller = @klass.run(req, request.params) - sendfile = nil - response.start(controller.status) do |head,out| - controller.headers.each do |k, v| - if k =~ /^X-SENDFILE$/i - sendfile = v - else - [*v].each do |vi| - head[k] = vi - end + sendfile, clength = nil + response.status = controller.status + controller.headers.each do |k, v| + if k =~ /^X-SENDFILE$/i + sendfile = v + elsif k =~ /^CONTENT-LENGTH$/i + clength = v.to_i + else + [*v].each do |vi| + response.header[k] = vi end end - response.send_header + end + response.send_status((sendfile and File.size(sendfile) or clength)) + response.send_header - if sendfile - response.send_file(sendfile) - elsif controller.body.respond_to? :read - while chunk = controller.body.read(16384) - @response.write(chunk) - end - if controller.body.respond_to? :close - controller.body.close - end - else - @response.write(controller.body) + if sendfile + response.send_file(sendfile) + elsif controller.body.respond_to? :read + while chunk = controller.body.read(16384) + response.write(chunk) + end + if controller.body.respond_to? :close + controller.body.close end + else + response.write(controller.body) end end end -- cgit v1.2.3-24-ge0c7