mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
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
This commit is contained in:
parent
3cf03ae9f3
commit
3e5ca782bc
1 changed files with 25 additions and 23 deletions
|
@ -34,32 +34,34 @@ 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
|
||||
end
|
||||
end
|
||||
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
|
||||
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
|
||||
@response.write(controller.body)
|
||||
[*v].each do |vi|
|
||||
response.header[k] = vi
|
||||
end
|
||||
end
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue