aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-25 18:35:44 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-25 18:35:44 -0700
commit51c7ac142d31095d4c699f44cc44ddea627da1eb (patch)
tree920c40c749272ebec57be8b26164829660781dff /actionpack/lib/action_dispatch
parent85a78d9358aa728298cd020cdc842b55c16f9549 (diff)
downloadrails-51c7ac142d31095d4c699f44cc44ddea627da1eb.tar.gz
rails-51c7ac142d31095d4c699f44cc44ddea627da1eb.tar.bz2
rails-51c7ac142d31095d4c699f44cc44ddea627da1eb.zip
provide a request and response to all controllers
Controllers should always have a request and response when responding. Since we make this The Rule(tm), then controllers don't need to be somewhere in limbo between "asking a response object for a rack response" or "I, myself contain a rack response". This duality leads to conditionals spread through the codebase that we can delete: * https://github.com/rails/rails/blob/85a78d9358aa728298cd020cdc842b55c16f9549/actionpack/lib/action_controller/metal.rb#L221-L223
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb3
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb10
2 files changed, 8 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index fd92e89231..c83b682f69 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -65,7 +65,7 @@ module ActionDispatch # :nodoc:
CONTENT_TYPE = "Content-Type".freeze
SET_COOKIE = "Set-Cookie".freeze
LOCATION = "Location".freeze
- NO_CONTENT_CODES = [204, 304]
+ NO_CONTENT_CODES = [100, 101, 102, 204, 205, 304]
cattr_accessor(:default_charset) { "utf-8" }
cattr_accessor(:default_headers)
@@ -396,6 +396,7 @@ module ActionDispatch # :nodoc:
if NO_CONTENT_CODES.include?(@status)
header.delete CONTENT_TYPE
+ header.delete 'Content-Length'
[status, header, []]
else
[status, header, RackBody.new(self)]
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 3e3a424df3..e4b8d5993e 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -27,8 +27,10 @@ module ActionDispatch
def dispatcher?; true; end
def serve(req)
- params = req.path_parameters
- dispatch(controller(req), params[:action], req)
+ params = req.path_parameters
+ controller = controller req
+ res = controller.make_response! req
+ dispatch(controller, params[:action], req, res)
rescue NameError => e
if @raise_on_name_error
raise ActionController::RoutingError, e.message, e.backtrace
@@ -43,8 +45,8 @@ module ActionDispatch
req.controller_class
end
- def dispatch(controller, action, req)
- controller.dispatch(action, req)
+ def dispatch(controller, action, req, res)
+ controller.dispatch(action, req, res)
end
end