Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9098 from firmhouse/add-head-requests

Make current_url? work with HEAD requests and remove caching_allowed? since it doesn't do anything
  • Loading branch information...
commit 764397f17d4140232c1aa62bc593b3e5f25485e7 2 parents 8fff05a + 4891388
Rafael Mendonça França rafaelfranca authored
5 actionpack/CHANGELOG.md
View
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Fix that CSRF protection and current_url? helper work with HEAD requests
+ now ActionDispatch::Head has been removed in favor of Rack::Head.
+
+ *Michiel Sikkes*
+
* Change asset_path to not include `SCRIPT_NAME` when it's used
from a mounted engine (fixes #8119).
4 actionpack/lib/action_controller/caching.rb
View
@@ -82,10 +82,6 @@ def view_cache_dependency(&dependency)
end
end
- def caching_allowed?
- request.get? && response.status == 200
- end
-
def view_cache_dependencies
self.class._view_cache_dependencies.map { |dep| instance_exec(&dep) }.compact
end
2  actionpack/lib/action_view/helpers/url_helper.rb
View
@@ -514,7 +514,7 @@ def current_page?(options)
"in a #request method"
end
- return false unless request.get?
+ return false unless request.get? || request.head?
url_string = url_for(options)
6 actionpack/test/template/url_helper_test.rb
View
@@ -437,6 +437,12 @@ def request_for_url(url, opts = {})
ActionDispatch::Request.new(env)
end
+ def test_current_page_with_http_head_method
+ @request = request_for_url("/", :method => :head)
+ assert current_page?(url_hash)
+ assert current_page?("http://www.example.com/")
+ end
+
def test_current_page_with_simple_url
@request = request_for_url("/")
assert current_page?(url_hash)
Please sign in to comment.
Something went wrong with that request. Please try again.