actionpack 3.0.0.beta2 → 3.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +37 -0
- data/lib/abstract_controller/rendering.rb +9 -11
- data/lib/action_controller.rb +0 -1
- data/lib/action_controller/base.rb +45 -44
- data/lib/action_controller/caching/pages.rb +2 -2
- data/lib/action_controller/deprecated/base.rb +21 -5
- data/lib/action_controller/metal/compatibility.rb +0 -2
- data/lib/action_controller/metal/cookies.rb +1 -1
- data/lib/action_controller/metal/helpers.rb +1 -1
- data/lib/action_controller/metal/http_authentication.rb +12 -5
- data/lib/action_controller/metal/responder.rb +3 -2
- data/lib/action_controller/polymorphic_routes.rb +1 -1
- data/lib/action_controller/railtie.rb +6 -1
- data/lib/action_controller/record_identifier.rb +2 -2
- data/lib/action_controller/test_case.rb +2 -0
- data/lib/action_dispatch/http/mime_negotiation.rb +2 -2
- data/lib/action_dispatch/http/request.rb +39 -21
- data/lib/action_dispatch/middleware/cookies.rb +18 -22
- data/lib/action_dispatch/middleware/params_parser.rb +8 -9
- data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +1 -1
- data/lib/action_dispatch/railtie.rb +1 -0
- data/lib/action_dispatch/routing.rb +24 -12
- data/lib/action_dispatch/routing/deprecated_mapper.rb +1 -1
- data/lib/action_dispatch/routing/mapper.rb +77 -51
- data/lib/action_dispatch/routing/route_set.rb +9 -5
- data/lib/action_dispatch/routing/url_for.rb +2 -3
- data/lib/action_dispatch/testing/integration.rb +24 -11
- data/lib/action_dispatch/testing/test_request.rb +2 -0
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_view/base.rb +8 -2
- data/lib/action_view/helpers.rb +3 -6
- data/lib/action_view/helpers/active_model_helper.rb +20 -265
- data/lib/action_view/helpers/asset_tag_helper.rb +46 -9
- data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
- data/lib/action_view/helpers/form_helper.rb +161 -120
- data/lib/action_view/helpers/form_options_helper.rb +0 -2
- data/lib/action_view/helpers/form_tag_helper.rb +76 -13
- data/lib/action_view/helpers/url_helper.rb +48 -21
- data/lib/action_view/locale/en.yml +0 -8
- data/lib/action_view/lookup_context.rb +11 -4
- data/lib/action_view/render/layouts.rb +32 -18
- data/lib/action_view/render/partials.rb +2 -2
- data/lib/action_view/template.rb +10 -1
- data/lib/action_view/test_case.rb +6 -1
- metadata +7 -8
- data/lib/action_controller/metal/verification.rb +0 -130
data/CHANGELOG
CHANGED
@@ -1,3 +1,40 @@
|
|
1
|
+
*Rails 3.0.0 [beta 3] (April 13th, 2010)*
|
2
|
+
|
3
|
+
* New option :as added to form_for allows to change the object name. The old <% form_for :client, @post %> becomes <% form_for @post, :as => :client %> [spastorino]
|
4
|
+
|
5
|
+
* Removed verify method in controllers. [JV]
|
6
|
+
It's now available as a plugin at http://github.com/rails/verification
|
7
|
+
|
8
|
+
* Removed input, form, error_messages_for and error_message_on from views. [JV]
|
9
|
+
It's now available as a plugin at http://github.com/rails/dynamic_form
|
10
|
+
|
11
|
+
* Routes can be scoped by controller module. [Jeremy Kemper]
|
12
|
+
|
13
|
+
# /session => Auth::SessionsController
|
14
|
+
scope :module => 'auth' do
|
15
|
+
resource :session
|
16
|
+
end
|
17
|
+
|
18
|
+
* Added #favicon_link_tag, it uses #image_path so in particular the favicon gets an asset ID [fxn]
|
19
|
+
|
20
|
+
* Fixed that default locale templates should be used if the current locale template is missing [DHH]
|
21
|
+
|
22
|
+
* Added all the new HTML5 form types as individual form tag methods (search, url, number, etc) #3646 [Stephen Celis]
|
23
|
+
|
24
|
+
* Changed the object used in routing constraints to be an instance of
|
25
|
+
ActionDispatch::Request rather than Rack::Request [YK]
|
26
|
+
|
27
|
+
* Changed ActionDispatch::Request#method to return a String, to be compatible
|
28
|
+
with Rack::Request. Added ActionDispatch::Request#method_symbol to
|
29
|
+
return a symbol form of the request method. [YK]
|
30
|
+
|
31
|
+
* Changed ActionDispatch::Request#method to return the original
|
32
|
+
method and #request_method to return the overridden method in the
|
33
|
+
case of methodoverride being used (this means that #method returns
|
34
|
+
"HEAD" and #request_method returns "GET" in HEAD requests). This
|
35
|
+
is for compatibility with Rack::Request [YK]
|
36
|
+
|
37
|
+
|
1
38
|
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
|
2
39
|
|
3
40
|
* #concat is now deprecated in favor of using <%= %> helpers [YK]
|
@@ -24,8 +24,7 @@ module AbstractController
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def locale=(value)
|
27
|
-
@
|
28
|
-
@lookup_context.update_details(:locale => @i18n_config.locale)
|
27
|
+
@lookup_context.locale = value
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
@@ -89,9 +88,16 @@ module AbstractController
|
|
89
88
|
# Normalize arguments, options and then delegates render_to_body and
|
90
89
|
# sticks the result in self.response_body.
|
91
90
|
def render(*args, &block)
|
91
|
+
self.response_body = render_to_string(*args, &block)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Raw rendering of a template to a string. Just convert the results of
|
95
|
+
# render_to_body into a String.
|
96
|
+
# :api: plugin
|
97
|
+
def render_to_string(*args, &block)
|
92
98
|
options = _normalize_args(*args, &block)
|
93
99
|
_normalize_options(options)
|
94
|
-
|
100
|
+
render_to_body(options)
|
95
101
|
end
|
96
102
|
|
97
103
|
# Raw rendering of a template to a Rack-compatible body.
|
@@ -101,14 +107,6 @@ module AbstractController
|
|
101
107
|
_render_template(options)
|
102
108
|
end
|
103
109
|
|
104
|
-
# Raw rendering of a template to a string. Just convert the results of
|
105
|
-
# render_to_body into a String.
|
106
|
-
# :api: plugin
|
107
|
-
def render_to_string(options={})
|
108
|
-
_normalize_options(options)
|
109
|
-
render_to_body(options)
|
110
|
-
end
|
111
|
-
|
112
110
|
# Find and renders a template based on the options given.
|
113
111
|
# :api: private
|
114
112
|
def _render_template(options) #:nodoc:
|
data/lib/action_controller.rb
CHANGED
@@ -2,48 +2,58 @@ module ActionController
|
|
2
2
|
class Base < Metal
|
3
3
|
abstract!
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
def self.without_modules(*modules)
|
6
|
+
modules = modules.map do |m|
|
7
|
+
m.is_a?(Symbol) ? ActionController.const_get(m) : m
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
include ActionController::HideActions
|
11
|
-
include ActionController::UrlFor
|
12
|
-
include ActionController::Redirecting
|
13
|
-
include ActionController::Rendering
|
14
|
-
include ActionController::Renderers::All
|
15
|
-
include ActionController::ConditionalGet
|
16
|
-
include ActionController::RackDelegation
|
10
|
+
MODULES - modules
|
11
|
+
end
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
include ActionController::MimeResponds
|
22
|
-
include ActionController::PolymorphicRoutes
|
13
|
+
MODULES = [
|
14
|
+
AbstractController::Layouts,
|
15
|
+
AbstractController::Translation,
|
23
16
|
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
Helpers,
|
18
|
+
HideActions,
|
19
|
+
UrlFor,
|
20
|
+
Redirecting,
|
21
|
+
Rendering,
|
22
|
+
Renderers::All,
|
23
|
+
ConditionalGet,
|
24
|
+
RackDelegation,
|
25
|
+
SessionManagement,
|
26
|
+
Caching,
|
27
|
+
MimeResponds,
|
28
|
+
PolymorphicRoutes,
|
29
|
+
ImplicitRender,
|
30
|
+
|
31
|
+
Cookies,
|
32
|
+
Flash,
|
33
|
+
RequestForgeryProtection,
|
34
|
+
Streaming,
|
35
|
+
RecordIdentifier,
|
36
|
+
HttpAuthentication::Basic::ControllerMethods,
|
37
|
+
HttpAuthentication::Digest::ControllerMethods,
|
38
|
+
|
39
|
+
# Add instrumentations hooks at the bottom, to ensure they instrument
|
40
|
+
# all the methods properly.
|
41
|
+
Instrumentation,
|
27
42
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
include ActionController::RequestForgeryProtection
|
32
|
-
include ActionController::Streaming
|
33
|
-
include ActionController::RecordIdentifier
|
34
|
-
include ActionController::HttpAuthentication::Basic::ControllerMethods
|
35
|
-
include ActionController::HttpAuthentication::Digest::ControllerMethods
|
43
|
+
# Before callbacks should also be executed the earliest as possible, so
|
44
|
+
# also include them at the bottom.
|
45
|
+
AbstractController::Callbacks,
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
47
|
+
# The same with rescue, append it at the end to wrap as much as possible.
|
48
|
+
Rescue
|
49
|
+
]
|
40
50
|
|
41
|
-
|
42
|
-
|
43
|
-
|
51
|
+
MODULES.each do |mod|
|
52
|
+
include mod
|
53
|
+
end
|
44
54
|
|
45
|
-
#
|
46
|
-
include ActionController::
|
55
|
+
# Rails 2.x compatibility
|
56
|
+
include ActionController::Compatibility
|
47
57
|
|
48
58
|
def self.inherited(klass)
|
49
59
|
::ActionController::Base.subclasses << klass.to_s
|
@@ -55,15 +65,6 @@ module ActionController
|
|
55
65
|
@subclasses ||= []
|
56
66
|
end
|
57
67
|
|
58
|
-
# This method has been moved to ActionDispatch::Request.filter_parameters
|
59
|
-
def self.filter_parameter_logging(*args, &block)
|
60
|
-
ActiveSupport::Deprecation.warn("Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead", caller)
|
61
|
-
filter = Rails.application.config.filter_parameters
|
62
|
-
filter.concat(args)
|
63
|
-
filter << block if block
|
64
|
-
filter
|
65
|
-
end
|
66
|
-
|
67
68
|
ActiveSupport.run_load_hooks(:action_controller, self)
|
68
69
|
end
|
69
70
|
end
|
@@ -38,22 +38,22 @@ module ActionController #:nodoc:
|
|
38
38
|
extend ActiveSupport::Concern
|
39
39
|
|
40
40
|
included do
|
41
|
-
@@page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
|
42
41
|
##
|
43
42
|
# :singleton-method:
|
44
43
|
# The cache directory should be the document root for the web server and is set using <tt>Base.page_cache_directory = "/document/root"</tt>.
|
45
44
|
# For Rails, this directory has already been set to Rails.public_path (which is usually set to <tt>RAILS_ROOT + "/public"</tt>). Changing
|
46
45
|
# this setting can be useful to avoid naming conflicts with files in <tt>public/</tt>, but doing so will likely require configuring your
|
47
46
|
# web server to look in the new location for cached files.
|
47
|
+
@@page_cache_directory = ''
|
48
48
|
cattr_accessor :page_cache_directory
|
49
49
|
|
50
|
-
@@page_cache_extension = '.html'
|
51
50
|
##
|
52
51
|
# :singleton-method:
|
53
52
|
# Most Rails requests do not have an extension, such as <tt>/weblog/new</tt>. In these cases, the page caching mechanism will add one in
|
54
53
|
# order to make it easy for the cached files to be picked up properly by the web server. By default, this cache extension is <tt>.html</tt>.
|
55
54
|
# If you want something else, like <tt>.php</tt> or <tt>.shtml</tt>, just set Base.page_cache_extension. In cases where a request already has an
|
56
55
|
# extension, such as <tt>.xml</tt> or <tt>.rss</tt>, page caching will not add an extension. This allows it to work well with RESTful apps.
|
56
|
+
@@page_cache_extension = '.html'
|
57
57
|
cattr_accessor :page_cache_extension
|
58
58
|
end
|
59
59
|
|
@@ -68,14 +68,11 @@ module ActionController
|
|
68
68
|
|
69
69
|
def cookie_verifier_secret=(value)
|
70
70
|
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret= is deprecated. " <<
|
71
|
-
"Please configure it on your application with config.
|
72
|
-
ActionController::Base.config.secret = value
|
71
|
+
"Please configure it on your application with config.secret_token=", caller
|
73
72
|
end
|
74
73
|
|
75
74
|
def cookie_verifier_secret
|
76
|
-
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret is deprecated.
|
77
|
-
"Please use ActionController::Base.config.secret instead.", caller
|
78
|
-
ActionController::Base.config.secret
|
75
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret is deprecated.", caller
|
79
76
|
end
|
80
77
|
|
81
78
|
def trusted_proxies=(value)
|
@@ -130,6 +127,25 @@ module ActionController
|
|
130
127
|
end
|
131
128
|
end
|
132
129
|
|
130
|
+
module DeprecatedBehavior
|
131
|
+
# This method has been moved to ActionDispatch::Request.filter_parameters
|
132
|
+
def filter_parameter_logging(*args, &block)
|
133
|
+
ActiveSupport::Deprecation.warn("Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead", caller)
|
134
|
+
filter = Rails.application.config.filter_parameters
|
135
|
+
filter.concat(args)
|
136
|
+
filter << block if block
|
137
|
+
filter
|
138
|
+
end
|
139
|
+
|
140
|
+
# This was moved to a plugin
|
141
|
+
def verify(*args)
|
142
|
+
ActiveSupport::Deprecation.warn "verify was removed from Rails and is now available as a plugin. " <<
|
143
|
+
"Please install it with `rails plugin install git://github.com/rails/verification.git`.", caller
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
extend DeprecatedBehavior
|
148
|
+
|
133
149
|
deprecated_config_writer :session_store
|
134
150
|
deprecated_config_writer :session_options
|
135
151
|
deprecated_config_accessor :relative_url_root, "relative_url_root is ineffective. Please stop using it"
|
@@ -159,7 +159,7 @@ module ActionController
|
|
159
159
|
|
160
160
|
# Authenticate with HTTP Digest, returns true or false
|
161
161
|
def authenticate_with_http_digest(realm = "Application", &password_procedure)
|
162
|
-
HttpAuthentication::Digest.authenticate(
|
162
|
+
HttpAuthentication::Digest.authenticate(request, realm, &password_procedure)
|
163
163
|
end
|
164
164
|
|
165
165
|
# Render output including the HTTP Digest authentication header
|
@@ -169,14 +169,15 @@ module ActionController
|
|
169
169
|
end
|
170
170
|
|
171
171
|
# Returns false on a valid response, true otherwise
|
172
|
-
def authenticate(
|
173
|
-
request.authorization && validate_digest_response(
|
172
|
+
def authenticate(request, realm, &password_procedure)
|
173
|
+
request.authorization && validate_digest_response(request, realm, &password_procedure)
|
174
174
|
end
|
175
175
|
|
176
176
|
# Returns false unless the request credentials response value matches the expected value.
|
177
177
|
# First try the password as a ha1 digest password. If this fails, then try it as a plain
|
178
178
|
# text password.
|
179
|
-
def validate_digest_response(
|
179
|
+
def validate_digest_response(request, realm, &password_procedure)
|
180
|
+
secret_key = secret_token(request)
|
180
181
|
credentials = decode_credentials_header(request)
|
181
182
|
valid_nonce = validate_nonce(secret_key, request, credentials[:nonce])
|
182
183
|
|
@@ -225,7 +226,7 @@ module ActionController
|
|
225
226
|
end
|
226
227
|
|
227
228
|
def authentication_header(controller, realm)
|
228
|
-
secret_key = controller.
|
229
|
+
secret_key = secret_token(controller.request)
|
229
230
|
nonce = self.nonce(secret_key)
|
230
231
|
opaque = opaque(secret_key)
|
231
232
|
controller.headers["WWW-Authenticate"] = %(Digest realm="#{realm}", qop="auth", algorithm=MD5, nonce="#{nonce}", opaque="#{opaque}")
|
@@ -238,6 +239,12 @@ module ActionController
|
|
238
239
|
controller.status = 401
|
239
240
|
end
|
240
241
|
|
242
|
+
def secret_token(request)
|
243
|
+
secret = request.env["action_dispatch.secret_token"]
|
244
|
+
raise "You must set config.secret_token in your app's config" if secret.blank?
|
245
|
+
secret
|
246
|
+
end
|
247
|
+
|
241
248
|
# Uses an MD5 digest based on time to generate a value to be used only once.
|
242
249
|
#
|
243
250
|
# A server-specified data string which should be uniquely generated each time a 401 response is made.
|
@@ -135,7 +135,6 @@ module ActionController #:nodoc:
|
|
135
135
|
def to_format
|
136
136
|
default_render
|
137
137
|
rescue ActionView::MissingTemplate => e
|
138
|
-
raise unless resourceful?
|
139
138
|
api_behavior(e)
|
140
139
|
end
|
141
140
|
|
@@ -154,6 +153,8 @@ module ActionController #:nodoc:
|
|
154
153
|
|
155
154
|
# This is the common behavior for "API" requests, like :xml and :json.
|
156
155
|
def api_behavior(error)
|
156
|
+
raise error unless resourceful?
|
157
|
+
|
157
158
|
if get?
|
158
159
|
display resource
|
159
160
|
elsif has_errors?
|
@@ -216,7 +217,7 @@ module ActionController #:nodoc:
|
|
216
217
|
# the verb is POST.
|
217
218
|
#
|
218
219
|
def default_action
|
219
|
-
@action ||= ACTIONS_FOR_VERBS[request.
|
220
|
+
@action ||= ACTIONS_FOR_VERBS[request.method_symbol]
|
220
221
|
end
|
221
222
|
end
|
222
223
|
end
|
@@ -120,7 +120,7 @@ module ActionController
|
|
120
120
|
end
|
121
121
|
|
122
122
|
%w(edit new).each do |action|
|
123
|
-
module_eval <<-EOT, __FILE__, __LINE__
|
123
|
+
module_eval <<-EOT, __FILE__, __LINE__ + 1
|
124
124
|
def #{action}_polymorphic_url(record_or_hash, options = {}) # def edit_polymorphic_url(record_or_hash, options = {})
|
125
125
|
polymorphic_url( # polymorphic_url(
|
126
126
|
record_or_hash, # record_or_hash,
|
@@ -44,6 +44,12 @@ module ActionController
|
|
44
44
|
ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger }
|
45
45
|
end
|
46
46
|
|
47
|
+
initializer "action_controller.page_cache_directory" do
|
48
|
+
ActiveSupport.on_load(:action_controller) do
|
49
|
+
self.page_cache_directory = Rails.public_path
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
47
53
|
initializer "action_controller.set_configs" do |app|
|
48
54
|
paths = app.config.paths
|
49
55
|
ac = app.config.action_controller
|
@@ -51,7 +57,6 @@ module ActionController
|
|
51
57
|
ac.assets_dir = paths.public.to_a.first
|
52
58
|
ac.javascripts_dir = paths.public.javascripts.to_a.first
|
53
59
|
ac.stylesheets_dir = paths.public.stylesheets.to_a.first
|
54
|
-
ac.secret = app.config.cookie_secret
|
55
60
|
|
56
61
|
ActiveSupport.on_load(:action_controller) do
|
57
62
|
self.config.merge!(ac)
|
@@ -6,10 +6,10 @@ module ActionController
|
|
6
6
|
# the view actions to a higher logical level. Example:
|
7
7
|
#
|
8
8
|
# # routes
|
9
|
-
#
|
9
|
+
# resources :posts
|
10
10
|
#
|
11
11
|
# # view
|
12
|
-
#
|
12
|
+
# <%= div_for(post) do %> <div id="post_45" class="post">
|
13
13
|
# <%= post.body %> What a wonderful world!
|
14
14
|
# <% end %> </div>
|
15
15
|
#
|
@@ -284,6 +284,8 @@ module ActionController
|
|
284
284
|
include ActionDispatch::TestProcess
|
285
285
|
include ActionController::TemplateAssertions
|
286
286
|
|
287
|
+
attr_reader :response, :request
|
288
|
+
|
287
289
|
# Executes a request simulating GET HTTP method and set/volley the response
|
288
290
|
def get(action, parameters = nil, session = nil, flash = nil)
|
289
291
|
process(action, parameters, session, flash, "GET")
|
@@ -48,7 +48,7 @@ module ActionDispatch
|
|
48
48
|
@env["action_dispatch.request.formats"] ||=
|
49
49
|
if parameters[:format]
|
50
50
|
Array(Mime[parameters[:format]])
|
51
|
-
elsif xhr? || (accept &&
|
51
|
+
elsif xhr? || (accept && accept !~ /,\s*\*\/\*/)
|
52
52
|
accepts
|
53
53
|
else
|
54
54
|
[Mime::HTML]
|
@@ -87,4 +87,4 @@ module ActionDispatch
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
|
-
end
|
90
|
+
end
|
@@ -45,47 +45,65 @@ module ActionDispatch
|
|
45
45
|
HTTP_METHODS = %w(get head put post delete options)
|
46
46
|
HTTP_METHOD_LOOKUP = HTTP_METHODS.inject({}) { |h, m| h[m] = h[m.upcase] = m.to_sym; h }
|
47
47
|
|
48
|
-
# Returns the
|
49
|
-
#
|
50
|
-
#
|
48
|
+
# Returns the HTTP \method that the application should see.
|
49
|
+
# In the case where the \method was overridden by a middleware
|
50
|
+
# (for instance, if a HEAD request was converted to a GET,
|
51
|
+
# or if a _method parameter was used to determine the \method
|
52
|
+
# the application should use), this \method returns the overridden
|
53
|
+
# value, not the original.
|
51
54
|
def request_method
|
52
|
-
method = env["
|
55
|
+
method = env["REQUEST_METHOD"]
|
53
56
|
HTTP_METHOD_LOOKUP[method] || raise(ActionController::UnknownHttpMethod, "#{method}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
|
57
|
+
method
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns a symbol form of the #request_method
|
61
|
+
def request_method_symbol
|
62
|
+
HTTP_METHOD_LOOKUP[request_method]
|
54
63
|
end
|
55
64
|
|
56
|
-
# Returns the
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# functionally equivalent from the application's perspective.)
|
65
|
+
# Returns the original value of the environment's REQUEST_METHOD,
|
66
|
+
# even if it was overridden by middleware. See #request_method for
|
67
|
+
# more information.
|
60
68
|
def method
|
61
|
-
method = env["
|
69
|
+
method = env["rack.methodoverride.original_method"] || env['REQUEST_METHOD']
|
62
70
|
HTTP_METHOD_LOOKUP[method] || raise(ActionController::UnknownHttpMethod, "#{method}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
|
71
|
+
method
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns a symbol form of the #method
|
75
|
+
def method_symbol
|
76
|
+
HTTP_METHOD_LOOKUP[method]
|
63
77
|
end
|
64
78
|
|
65
|
-
# Is this a GET (or HEAD) request?
|
79
|
+
# Is this a GET (or HEAD) request?
|
80
|
+
# Equivalent to <tt>request.request_method == :get</tt>.
|
66
81
|
def get?
|
67
|
-
|
82
|
+
HTTP_METHOD_LOOKUP[request_method] == :get
|
68
83
|
end
|
69
84
|
|
70
|
-
# Is this a POST request?
|
85
|
+
# Is this a POST request?
|
86
|
+
# Equivalent to <tt>request.request_method == :post</tt>.
|
71
87
|
def post?
|
72
|
-
|
88
|
+
HTTP_METHOD_LOOKUP[request_method] == :post
|
73
89
|
end
|
74
90
|
|
75
|
-
# Is this a PUT request?
|
91
|
+
# Is this a PUT request?
|
92
|
+
# Equivalent to <tt>request.request_method == :put</tt>.
|
76
93
|
def put?
|
77
|
-
|
94
|
+
HTTP_METHOD_LOOKUP[request_method] == :put
|
78
95
|
end
|
79
96
|
|
80
|
-
# Is this a DELETE request?
|
97
|
+
# Is this a DELETE request?
|
98
|
+
# Equivalent to <tt>request.request_method == :delete</tt>.
|
81
99
|
def delete?
|
82
|
-
|
100
|
+
HTTP_METHOD_LOOKUP[request_method] == :delete
|
83
101
|
end
|
84
102
|
|
85
|
-
# Is this a HEAD request?
|
86
|
-
#
|
103
|
+
# Is this a HEAD request?
|
104
|
+
# Equivalent to <tt>request.method == :head</tt>.
|
87
105
|
def head?
|
88
|
-
|
106
|
+
HTTP_METHOD_LOOKUP[method] == :head
|
89
107
|
end
|
90
108
|
|
91
109
|
# Provides access to the request's HTTP headers, for example:
|
@@ -96,7 +114,7 @@ module ActionDispatch
|
|
96
114
|
end
|
97
115
|
|
98
116
|
def forgery_whitelisted?
|
99
|
-
|
117
|
+
get? || xhr? || content_mime_type.nil? || !content_mime_type.verify_request?
|
100
118
|
end
|
101
119
|
|
102
120
|
def media_type
|