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,31 +34,33 @@ module Mongrel
|
||||||
def process(request, response)
|
def process(request, response)
|
||||||
req = StringIO.new(request.body)
|
req = StringIO.new(request.body)
|
||||||
controller = @klass.run(req, request.params)
|
controller = @klass.run(req, request.params)
|
||||||
sendfile = nil
|
sendfile, clength = nil
|
||||||
response.start(controller.status) do |head,out|
|
response.status = controller.status
|
||||||
controller.headers.each do |k, v|
|
controller.headers.each do |k, v|
|
||||||
if k =~ /^X-SENDFILE$/i
|
if k =~ /^X-SENDFILE$/i
|
||||||
sendfile = v
|
sendfile = v
|
||||||
|
elsif k =~ /^CONTENT-LENGTH$/i
|
||||||
|
clength = v.to_i
|
||||||
else
|
else
|
||||||
[*v].each do |vi|
|
[*v].each do |vi|
|
||||||
head[k] = vi
|
response.header[k] = vi
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
response.send_status((sendfile and File.size(sendfile) or clength))
|
||||||
response.send_header
|
response.send_header
|
||||||
|
|
||||||
if sendfile
|
if sendfile
|
||||||
response.send_file(sendfile)
|
response.send_file(sendfile)
|
||||||
elsif controller.body.respond_to? :read
|
elsif controller.body.respond_to? :read
|
||||||
while chunk = controller.body.read(16384)
|
while chunk = controller.body.read(16384)
|
||||||
@response.write(chunk)
|
response.write(chunk)
|
||||||
end
|
end
|
||||||
if controller.body.respond_to? :close
|
if controller.body.respond_to? :close
|
||||||
controller.body.close
|
controller.body.close
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@response.write(controller.body)
|
response.write(controller.body)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue