aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/dispatcher.rb27
-rw-r--r--actionpack/lib/action_controller/rack_process.rb3
2 files changed, 10 insertions, 20 deletions
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index 5a185eb59c..11c4f057d8 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -65,18 +65,23 @@ module ActionController
include ActiveSupport::Callbacks
define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
- # DEPRECATE: Remove arguments
+ # DEPRECATE: Remove arguments, since they are only used by CGI
def initialize(output = $stdout, request = nil, response = nil)
- @output, @request, @response = output, request, response
+ @output = output
@app = @@middleware.build(lambda { |env| self.dup._call(env) })
end
def dispatch
begin
run_callbacks :before_dispatch
- handle_request
+ controller = Routing::Routes.recognize(@request)
+ controller.process(@request, @response).to_a
rescue Exception => exception
- failsafe_rescue exception
+ if controller ||= (::ApplicationController rescue Base)
+ controller.process_with_exception(@request, @response, exception).to_a
+ else
+ raise exception
+ end
ensure
run_callbacks :after_dispatch, :enumerator => :reverse_each
end
@@ -123,19 +128,5 @@ module ActionController
return if @request.key?("rack.test")
ActiveRecord::Base.clear_active_connections!
end
-
- protected
- def handle_request
- @controller = Routing::Routes.recognize(@request)
- @controller.process(@request, @response).out
- end
-
- def failsafe_rescue(exception)
- if @controller ||= (::ApplicationController rescue Base)
- @controller.process_with_exception(@request, @response, exception).out
- else
- raise exception
- end
- end
end
end
diff --git a/actionpack/lib/action_controller/rack_process.rb b/actionpack/lib/action_controller/rack_process.rb
index 778c3c256f..8483f8e289 100644
--- a/actionpack/lib/action_controller/rack_process.rb
+++ b/actionpack/lib/action_controller/rack_process.rb
@@ -83,7 +83,7 @@ module ActionController #:nodoc:
@status || super
end
- def out(&block)
+ def to_a(&block)
@block = block
@status = headers.delete("Status")
if [204, 304].include?(status.to_i)
@@ -93,7 +93,6 @@ module ActionController #:nodoc:
[status, headers.to_hash, self]
end
end
- alias to_a out
def each(&callback)
if @body.respond_to?(:call)