aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-xactionpack/lib/action_controller/request.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index 505fe0777f..98d28d24b8 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -13,14 +13,18 @@ module ActionController
@parameters ||= request_parameters.update(query_parameters).update(path_parameters).with_indifferent_access
end
- # Returns the HTTP request method as a lowercase symbol (:get, for example)
+ # Returns the HTTP request method as a lowercase symbol (:get, for example). Note, HEAD is returned as :get
+ # since the two are supposedly to be functionaly equivilent for all purposes except that HEAD won't return a response
+ # body (which Rails also takes care of elsewhere).
def method
@request_method ||= (!parameters[:_method].blank? && @env['REQUEST_METHOD'] == 'POST') ?
parameters[:_method].to_s.downcase.to_sym :
@env['REQUEST_METHOD'].downcase.to_sym
+
+ @request_method == :head ? :get : @request_method
end
- # Is this a GET request? Equivalent to request.method == :get
+ # Is this a GET (or HEAD) request? Equivalent to request.method == :get
def get?
method == :get
end
@@ -40,9 +44,10 @@ module ActionController
method == :delete
end
- # Is this a HEAD request? Equivalent to request.method == :head
+ # Is this a HEAD request? HEAD is mapped as :get for request.method, so here we ask the
+ # REQUEST_METHOD header directly. Thus, for head, both get? and head? will return true.
def head?
- method == :head
+ @env['REQUEST_METHOD'].downcase.to_sym == :head
end
# Determine whether the body of a HTTP call is URL-encoded (default)