Skip to content

Commit

Permalink
Remove ActionDispatch::Head middleware in favor of Rack::Head
Browse files Browse the repository at this point in the history
Closes #7110 there's more work to do on rack-cache issue 69
  • Loading branch information
spastorino committed Jul 23, 2012
1 parent 998189a commit 449039a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 32 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/http/request.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def delete?
end end


# Is this a HEAD request? # Is this a HEAD request?
# Equivalent to <tt>request.method_symbol == :head</tt>. # Equivalent to <tt>request.request_method_symbol == :head</tt>.
def head? def head?
HTTP_METHOD_LOOKUP[method] == :head HTTP_METHOD_LOOKUP[request_method] == :head
end end


# Provides access to the request's HTTP headers, for example: # Provides access to the request's HTTP headers, for example:
Expand Down
18 changes: 0 additions & 18 deletions actionpack/lib/action_dispatch/middleware/head.rb

This file was deleted.

2 changes: 1 addition & 1 deletion actionpack/test/abstract_unit.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def self.build_app(routes = nil)
middleware.use "ActionDispatch::ParamsParser" middleware.use "ActionDispatch::ParamsParser"
middleware.use "ActionDispatch::Cookies" middleware.use "ActionDispatch::Cookies"
middleware.use "ActionDispatch::Flash" middleware.use "ActionDispatch::Flash"
middleware.use "ActionDispatch::Head" middleware.use "Rack::Head"
yield(middleware) if block_given? yield(middleware) if block_given?
end end
end end
Expand Down
8 changes: 0 additions & 8 deletions actionpack/test/dispatch/request_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -461,14 +461,6 @@ def url_for(options = {})
end end
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 test "post masquerading as patch" do
request = stub_request 'REQUEST_METHOD' => 'PATCH', "rack.methodoverride.original_method" => "POST" request = stub_request 'REQUEST_METHOD' => 'PATCH', "rack.methodoverride.original_method" => "POST"
assert_equal "POST", request.method assert_equal "POST", request.method
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/application.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def default_middleware_stack #:nodoc:
end end


middleware.use ::ActionDispatch::ParamsParser middleware.use ::ActionDispatch::ParamsParser
middleware.use ::ActionDispatch::Head middleware.use ::Rack::Head
middleware.use ::Rack::ConditionalGet middleware.use ::Rack::ConditionalGet
middleware.use ::Rack::ETag, "no-cache" middleware.use ::Rack::ETag, "no-cache"


Expand Down
2 changes: 1 addition & 1 deletion railties/test/application/middleware_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def app
"ActionDispatch::Session::CookieStore", "ActionDispatch::Session::CookieStore",
"ActionDispatch::Flash", "ActionDispatch::Flash",
"ActionDispatch::ParamsParser", "ActionDispatch::ParamsParser",
"ActionDispatch::Head", "Rack::Head",
"Rack::ConditionalGet", "Rack::ConditionalGet",
"Rack::ETag", "Rack::ETag",
"ActionDispatch::BestStandardsSupport" "ActionDispatch::BestStandardsSupport"
Expand Down
8 changes: 7 additions & 1 deletion railties/test/application/rack/logger_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ def logs
@logs ||= @logger.logged(:info) @logs ||= @logger.logged(:info)
end end


test "logger logs proper HTTP verb and path" do test "logger logs proper HTTP GET verb and path" do
get "/blah" get "/blah"
wait wait
assert_match(/^Started GET "\/blah"/, logs[0]) assert_match(/^Started GET "\/blah"/, logs[0])
end 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 test "logger logs HTTP verb override" do
post "/", {:_method => 'put'} post "/", {:_method => 'put'}
wait wait
Expand Down

0 comments on commit 449039a

Please sign in to comment.