Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove ActionDispatch::Head middleware in favor of Rack::Head

Closes #7110 there's more work to do on rack-cache issue 69
  • Loading branch information...
commit 449039a86d802871b707dfb51ac1ed96d53526f9 1 parent 998189a
@spastorino spastorino authored
View
4 actionpack/lib/action_dispatch/http/request.rb
@@ -119,9 +119,9 @@ def delete?
end
# Is this a HEAD request?
- # Equivalent to <tt>request.method_symbol == :head</tt>.
+ # Equivalent to <tt>request.request_method_symbol == :head</tt>.
def head?
- HTTP_METHOD_LOOKUP[method] == :head
+ HTTP_METHOD_LOOKUP[request_method] == :head
end
# Provides access to the request's HTTP headers, for example:
View
18 actionpack/lib/action_dispatch/middleware/head.rb
@@ -1,18 +0,0 @@
-module ActionDispatch
- class Head
- def initialize(app)
- @app = app
- end
-
- def call(env)
- if env["REQUEST_METHOD"] == "HEAD"
- env["REQUEST_METHOD"] = "GET"
- env["rack.methodoverride.original_method"] = "HEAD"
- status, headers, _ = @app.call(env)
- [status, headers, []]
- else
- @app.call(env)
- end
- end
- end
-end
View
2  actionpack/test/abstract_unit.rb
@@ -171,7 +171,7 @@ def self.build_app(routes = nil)
middleware.use "ActionDispatch::ParamsParser"
middleware.use "ActionDispatch::Cookies"
middleware.use "ActionDispatch::Flash"
- middleware.use "ActionDispatch::Head"
+ middleware.use "Rack::Head"
yield(middleware) if block_given?
end
end
View
8 actionpack/test/dispatch/request_test.rb
@@ -461,14 +461,6 @@ def url_for(options = {})
end
end
- test "head masquerading as get" do
- request = stub_request 'REQUEST_METHOD' => 'GET', "rack.methodoverride.original_method" => "HEAD"
- assert_equal "HEAD", request.method
- assert_equal "GET", request.request_method
- assert request.get?
- assert request.head?
- end
-
test "post masquerading as patch" do
request = stub_request 'REQUEST_METHOD' => 'PATCH', "rack.methodoverride.original_method" => "POST"
assert_equal "POST", request.method
View
2  railties/lib/rails/application.rb
@@ -310,7 +310,7 @@ def default_middleware_stack #:nodoc:
end
middleware.use ::ActionDispatch::ParamsParser
- middleware.use ::ActionDispatch::Head
+ middleware.use ::Rack::Head
middleware.use ::Rack::ConditionalGet
middleware.use ::Rack::ETag, "no-cache"
View
2  railties/test/application/middleware_test.rb
@@ -45,7 +45,7 @@ def app
"ActionDispatch::Session::CookieStore",
"ActionDispatch::Flash",
"ActionDispatch::ParamsParser",
- "ActionDispatch::Head",
+ "Rack::Head",
"Rack::ConditionalGet",
"Rack::ETag",
"ActionDispatch::BestStandardsSupport"
View
8 railties/test/application/rack/logger_test.rb
@@ -26,12 +26,18 @@ def logs
@logs ||= @logger.logged(:info)
end
- test "logger logs proper HTTP verb and path" do
+ test "logger logs proper HTTP GET verb and path" do
get "/blah"
wait
assert_match(/^Started GET "\/blah"/, logs[0])
end
+ test "logger logs proper HTTP HEAD verb and path" do
+ head "/blah"
+ wait
+ assert_match(/^Started HEAD "\/blah"/, logs[0])
+ end
+
test "logger logs HTTP verb override" do
post "/", {:_method => 'put'}
wait
Please sign in to comment.
Something went wrong with that request. Please try again.