Class: ActionDispatch::Executor
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Inherits: | Object |
| Defined in: | actionpack/lib/action_dispatch/middleware/executor.rb |
Class Method Summary
- .new(app, executor) ⇒ Executor constructor
Instance Method Summary
Constructor Details
.new(app, executor) ⇒ Executor
# File 'actionpack/lib/action_dispatch/middleware/executor.rb', line 9
def initialize(app, executor) @app, @executor = app, executor end
Instance Method Details
#call(env)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/executor.rb', line 13
def call(env) state = @executor.run!(reset: true) completed = false finalize = -> { next if completed completed = true state.complete! } if response_finished = env["rack.response_finished"] response_finished << proc { finalize.call } end begin response = @app.call(env) if env["action_dispatch.report_exception"] error = env["action_dispatch.exception"] @executor.error_reporter.report(error, handled: false, source: "application.action_dispatch") end if hijacked?(env, response) # `close` and `rack.response_finished` may never fire on hijack. # Release eagerly; the request's autoloaded code is resolved by now. finalize.call elsif !response_finished response << ::Rack::BodyProxy.new(response.pop) { finalize.call } end returned = true response rescue Exception => error request = ActionDispatch::Request.new env backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner") wrapper = ExceptionWrapper.new(backtrace_cleaner, error) @executor.error_reporter.report(wrapper.unwrapped_exception, handled: false, source: "application.action_dispatch") raise ensure if !returned && !response_finished finalize.call end end end
#hijacked?(env, response) ⇒ Boolean (private)
# File 'actionpack/lib/action_dispatch/middleware/executor.rb', line 58
def hijacked?(env, response) return false unless response env["rack.hijack_io"] || response.first == 101 end