actionpack 7.2.3.1 → 8.1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +606 -120
- data/lib/abstract_controller/asset_paths.rb +4 -2
- data/lib/abstract_controller/base.rb +11 -5
- data/lib/abstract_controller/caching.rb +6 -3
- data/lib/abstract_controller/callbacks.rb +6 -0
- data/lib/abstract_controller/logger.rb +2 -1
- data/lib/abstract_controller/rendering.rb +0 -1
- data/lib/action_controller/api.rb +1 -0
- data/lib/action_controller/base.rb +3 -2
- data/lib/action_controller/caching.rb +1 -2
- data/lib/action_controller/form_builder.rb +4 -4
- data/lib/action_controller/log_subscriber.rb +22 -3
- data/lib/action_controller/metal/allow_browser.rb +12 -2
- data/lib/action_controller/metal/conditional_get.rb +30 -1
- data/lib/action_controller/metal/data_streaming.rb +5 -5
- data/lib/action_controller/metal/exceptions.rb +5 -0
- data/lib/action_controller/metal/flash.rb +1 -4
- data/lib/action_controller/metal/head.rb +3 -1
- data/lib/action_controller/metal/http_authentication.rb +1 -1
- data/lib/action_controller/metal/instrumentation.rb +1 -2
- data/lib/action_controller/metal/live.rb +83 -31
- data/lib/action_controller/metal/permissions_policy.rb +9 -0
- data/lib/action_controller/metal/rate_limiting.rb +39 -9
- data/lib/action_controller/metal/redirecting.rb +107 -14
- data/lib/action_controller/metal/renderers.rb +29 -9
- data/lib/action_controller/metal/rendering.rb +16 -3
- data/lib/action_controller/metal/request_forgery_protection.rb +18 -10
- data/lib/action_controller/metal/rescue.rb +9 -0
- data/lib/action_controller/metal/streaming.rb +5 -84
- data/lib/action_controller/metal/strong_parameters.rb +294 -98
- data/lib/action_controller/railtie.rb +35 -15
- data/lib/action_controller/structured_event_subscriber.rb +116 -0
- data/lib/action_controller/test_case.rb +12 -2
- data/lib/action_dispatch/http/cache.rb +143 -12
- data/lib/action_dispatch/http/content_security_policy.rb +14 -1
- data/lib/action_dispatch/http/filter_parameters.rb +5 -3
- data/lib/action_dispatch/http/mime_negotiation.rb +66 -2
- data/lib/action_dispatch/http/mime_types.rb +1 -0
- data/lib/action_dispatch/http/param_builder.rb +187 -0
- data/lib/action_dispatch/http/param_error.rb +26 -0
- data/lib/action_dispatch/http/parameters.rb +3 -3
- data/lib/action_dispatch/http/permissions_policy.rb +8 -1
- data/lib/action_dispatch/http/query_parser.rb +55 -0
- data/lib/action_dispatch/http/request.rb +70 -21
- data/lib/action_dispatch/http/response.rb +52 -17
- data/lib/action_dispatch/http/url.rb +112 -16
- data/lib/action_dispatch/journey/formatter.rb +5 -0
- data/lib/action_dispatch/journey/gtg/simulator.rb +33 -12
- data/lib/action_dispatch/journey/gtg/transition_table.rb +33 -41
- data/lib/action_dispatch/journey/nodes/node.rb +2 -1
- data/lib/action_dispatch/journey/parser.rb +99 -196
- data/lib/action_dispatch/journey/route.rb +45 -31
- data/lib/action_dispatch/journey/router/utils.rb +9 -15
- data/lib/action_dispatch/journey/router.rb +59 -81
- data/lib/action_dispatch/journey/routes.rb +7 -0
- data/lib/action_dispatch/journey/scanner.rb +44 -42
- data/lib/action_dispatch/journey/visitors.rb +55 -23
- data/lib/action_dispatch/journey/visualizer/fsm.js +4 -6
- data/lib/action_dispatch/log_subscriber.rb +7 -3
- data/lib/action_dispatch/middleware/cookies.rb +24 -5
- data/lib/action_dispatch/middleware/debug_exceptions.rb +24 -5
- data/lib/action_dispatch/middleware/debug_view.rb +11 -5
- data/lib/action_dispatch/middleware/exception_wrapper.rb +12 -12
- data/lib/action_dispatch/middleware/executor.rb +12 -2
- data/lib/action_dispatch/middleware/host_authorization.rb +3 -2
- data/lib/action_dispatch/middleware/public_exceptions.rb +1 -5
- data/lib/action_dispatch/middleware/remote_ip.rb +61 -24
- data/lib/action_dispatch/middleware/request_id.rb +2 -1
- data/lib/action_dispatch/middleware/session/abstract_store.rb +5 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +44 -4
- data/lib/action_dispatch/middleware/session/cookie_store.rb +0 -3
- data/lib/action_dispatch/middleware/ssl.rb +13 -3
- data/lib/action_dispatch/middleware/templates/rescues/_copy_button.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +3 -5
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +9 -5
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +4 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +50 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +7 -8
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -0
- data/lib/action_dispatch/railtie.rb +21 -0
- data/lib/action_dispatch/request/session.rb +1 -0
- data/lib/action_dispatch/request/utils.rb +9 -3
- data/lib/action_dispatch/routing/inspector.rb +80 -57
- data/lib/action_dispatch/routing/mapper.rb +404 -223
- data/lib/action_dispatch/routing/polymorphic_routes.rb +2 -2
- data/lib/action_dispatch/routing/redirection.rb +10 -7
- data/lib/action_dispatch/routing/route_set.rb +21 -12
- data/lib/action_dispatch/routing/routes_proxy.rb +1 -0
- data/lib/action_dispatch/structured_event_subscriber.rb +20 -0
- data/lib/action_dispatch/system_test_case.rb +3 -3
- data/lib/action_dispatch/system_testing/browser.rb +15 -22
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +2 -2
- data/lib/action_dispatch/testing/assertions/response.rb +26 -2
- data/lib/action_dispatch/testing/assertions/routing.rb +27 -15
- data/lib/action_dispatch/testing/integration.rb +18 -7
- data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +1 -1
- data/lib/action_dispatch.rb +14 -4
- data/lib/action_pack/gem_version.rb +3 -3
- metadata +18 -48
- data/lib/action_dispatch/journey/parser.y +0 -50
- data/lib/action_dispatch/journey/parser_extras.rb +0 -33
|
@@ -7,8 +7,10 @@ module AbstractController
|
|
|
7
7
|
extend ActiveSupport::Concern
|
|
8
8
|
|
|
9
9
|
included do
|
|
10
|
-
|
|
11
|
-
:stylesheets_dir, :default_asset_host_protocol, :relative_url_root
|
|
10
|
+
singleton_class.delegate :asset_host, :asset_host=, :assets_dir, :assets_dir=, :javascripts_dir, :javascripts_dir=,
|
|
11
|
+
:stylesheets_dir, :stylesheets_dir=, :default_asset_host_protocol, :default_asset_host_protocol=, :relative_url_root, :relative_url_root=, to: :config
|
|
12
|
+
delegate :asset_host, :asset_host=, :assets_dir, :assets_dir=, :javascripts_dir, :javascripts_dir=,
|
|
13
|
+
:stylesheets_dir, :stylesheets_dir=, :default_asset_host_protocol, :default_asset_host_protocol=, :relative_url_root, :relative_url_root=, to: :config
|
|
12
14
|
end
|
|
13
15
|
end
|
|
14
16
|
end
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
# :markup: markdown
|
|
4
4
|
|
|
5
5
|
require "abstract_controller/error"
|
|
6
|
-
require "active_support/configurable"
|
|
7
6
|
require "active_support/descendants_tracker"
|
|
8
7
|
require "active_support/core_ext/module/anonymous"
|
|
9
8
|
require "active_support/core_ext/module/attr_internal"
|
|
@@ -47,7 +46,7 @@ module AbstractController
|
|
|
47
46
|
# Returns the formats that can be processed by the controller.
|
|
48
47
|
attr_internal :formats
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
class_attribute :config, instance_predicate: false, default: ActiveSupport::OrderedOptions.new
|
|
51
50
|
extend ActiveSupport::DescendantsTracker
|
|
52
51
|
|
|
53
52
|
class << self
|
|
@@ -65,6 +64,7 @@ module AbstractController
|
|
|
65
64
|
unless klass.instance_variable_defined?(:@abstract)
|
|
66
65
|
klass.instance_variable_set(:@abstract, false)
|
|
67
66
|
end
|
|
67
|
+
klass.config = ActiveSupport::InheritableOptions.new(config)
|
|
68
68
|
super
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -95,9 +95,7 @@ module AbstractController
|
|
|
95
95
|
# All public instance methods of this class, including ancestors except for
|
|
96
96
|
# public instance methods of Base and its ancestors.
|
|
97
97
|
methods = public_instance_methods(true) - internal_methods
|
|
98
|
-
|
|
99
|
-
methods.concat(public_instance_methods(false))
|
|
100
|
-
methods.map!(&:to_s)
|
|
98
|
+
methods.map!(&:name)
|
|
101
99
|
methods.to_set
|
|
102
100
|
end
|
|
103
101
|
end
|
|
@@ -121,6 +119,10 @@ module AbstractController
|
|
|
121
119
|
@controller_path ||= name.delete_suffix("Controller").underscore unless anonymous?
|
|
122
120
|
end
|
|
123
121
|
|
|
122
|
+
def configure # :nodoc:
|
|
123
|
+
yield config
|
|
124
|
+
end
|
|
125
|
+
|
|
124
126
|
# Refresh the cached action_methods when a new action_method is added.
|
|
125
127
|
def method_added(name)
|
|
126
128
|
super
|
|
@@ -190,6 +192,10 @@ module AbstractController
|
|
|
190
192
|
true
|
|
191
193
|
end
|
|
192
194
|
|
|
195
|
+
def config # :nodoc:
|
|
196
|
+
@_config ||= self.class.config.inheritable_copy
|
|
197
|
+
end
|
|
198
|
+
|
|
193
199
|
def inspect # :nodoc:
|
|
194
200
|
"#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
|
|
195
201
|
end
|
|
@@ -32,13 +32,16 @@ module AbstractController
|
|
|
32
32
|
included do
|
|
33
33
|
extend ConfigMethods
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
singleton_class.delegate :default_static_extension, :default_static_extension=, to: :config
|
|
36
|
+
delegate :default_static_extension, :default_static_extension=, to: :config
|
|
36
37
|
self.default_static_extension ||= ".html"
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
singleton_class.delegate :perform_caching, :perform_caching=, to: :config
|
|
40
|
+
delegate :perform_caching, :perform_caching=, to: :config
|
|
39
41
|
self.perform_caching = true if perform_caching.nil?
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
singleton_class.delegate :enable_fragment_cache_logging, :enable_fragment_cache_logging=, to: :config
|
|
44
|
+
delegate :enable_fragment_cache_logging, :enable_fragment_cache_logging=, to: :config
|
|
42
45
|
self.enable_fragment_cache_logging = false
|
|
43
46
|
|
|
44
47
|
class_attribute :_view_cache_dependencies, default: []
|
|
@@ -29,6 +29,8 @@ module AbstractController
|
|
|
29
29
|
# ActiveSupport::Callbacks.
|
|
30
30
|
include ActiveSupport::Callbacks
|
|
31
31
|
|
|
32
|
+
DEFAULT_INTERNAL_METHODS = [:_run_process_action_callbacks].freeze # :nodoc:
|
|
33
|
+
|
|
32
34
|
included do
|
|
33
35
|
define_callbacks :process_action,
|
|
34
36
|
terminator: ->(controller, result_lambda) { result_lambda.call; controller.performed? },
|
|
@@ -251,6 +253,10 @@ module AbstractController
|
|
|
251
253
|
# *_action is the same as append_*_action
|
|
252
254
|
alias_method :"append_#{callback}_action", :"#{callback}_action"
|
|
253
255
|
end
|
|
256
|
+
|
|
257
|
+
def internal_methods # :nodoc:
|
|
258
|
+
super.concat(DEFAULT_INTERNAL_METHODS)
|
|
259
|
+
end
|
|
254
260
|
end
|
|
255
261
|
|
|
256
262
|
private
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
require "action_view"
|
|
6
6
|
require "action_controller/log_subscriber"
|
|
7
|
+
require "action_controller/structured_event_subscriber"
|
|
7
8
|
require "action_controller/metal/params_wrapper"
|
|
8
9
|
|
|
9
10
|
module ActionController
|
|
@@ -128,7 +129,7 @@ module ActionController
|
|
|
128
129
|
#
|
|
129
130
|
# Action Controller sends content to the user by using one of five rendering
|
|
130
131
|
# methods. The most versatile and common is the rendering of a template.
|
|
131
|
-
#
|
|
132
|
+
# Also included with \Rails is Action View, which enables rendering of ERB
|
|
132
133
|
# templates. It's automatically configured. The controller passes objects to the
|
|
133
134
|
# view by assigning instance variables:
|
|
134
135
|
#
|
|
@@ -266,7 +267,7 @@ module ActionController
|
|
|
266
267
|
ParamsWrapper
|
|
267
268
|
]
|
|
268
269
|
|
|
269
|
-
# Note: Documenting these severely
|
|
270
|
+
# Note: Documenting these severely degrades the performance of rdoc
|
|
270
271
|
# :stopdoc:
|
|
271
272
|
include AbstractController::Rendering
|
|
272
273
|
include AbstractController::Translation
|
|
@@ -9,9 +9,8 @@ module ActionController
|
|
|
9
9
|
# of calculations, renderings, and database calls around for subsequent
|
|
10
10
|
# requests.
|
|
11
11
|
#
|
|
12
|
-
# You can read more about each approach by clicking the modules below.
|
|
13
|
-
#
|
|
14
12
|
# Note: To turn off all caching provided by Action Controller, set
|
|
13
|
+
#
|
|
15
14
|
# config.action_controller.perform_caching = false
|
|
16
15
|
#
|
|
17
16
|
# ## Caching stores
|
|
@@ -22,10 +22,10 @@ module ActionController
|
|
|
22
22
|
# default_form_builder AdminFormBuilder
|
|
23
23
|
# end
|
|
24
24
|
#
|
|
25
|
-
# Then in the view any form using `form_for` will be an
|
|
26
|
-
# specified form builder:
|
|
25
|
+
# Then in the view any form using `form_with` or `form_for` will be an
|
|
26
|
+
# instance of the specified form builder:
|
|
27
27
|
#
|
|
28
|
-
# <%=
|
|
28
|
+
# <%= form_with(model: @instance) do |builder| %>
|
|
29
29
|
# <%= builder.special_field(:name) %>
|
|
30
30
|
# <% end %>
|
|
31
31
|
module FormBuilder
|
|
@@ -40,7 +40,7 @@ module ActionController
|
|
|
40
40
|
# rendered by this controller and its subclasses.
|
|
41
41
|
#
|
|
42
42
|
# #### Parameters
|
|
43
|
-
# * `builder` - Default form builder
|
|
43
|
+
# * `builder` - Default form builder. Accepts a subclass of
|
|
44
44
|
# ActionView::Helpers::FormBuilder
|
|
45
45
|
def default_form_builder(builder)
|
|
46
46
|
self._default_form_builder = builder
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# :markup: markdown
|
|
4
|
-
|
|
5
3
|
module ActionController
|
|
6
|
-
class LogSubscriber < ActiveSupport::LogSubscriber
|
|
4
|
+
class LogSubscriber < ActiveSupport::LogSubscriber # :nodoc:
|
|
7
5
|
INTERNAL_PARAMS = %w(controller action format _method only_path)
|
|
8
6
|
|
|
7
|
+
class_attribute :backtrace_cleaner, default: ActiveSupport::BacktraceCleaner.new
|
|
8
|
+
|
|
9
9
|
def start_processing(event)
|
|
10
10
|
return unless logger.info?
|
|
11
11
|
|
|
@@ -49,6 +49,17 @@ module ActionController
|
|
|
49
49
|
end
|
|
50
50
|
subscribe_log_level :halted_callback, :info
|
|
51
51
|
|
|
52
|
+
# Manually subscribed below
|
|
53
|
+
def rescue_from_callback(event)
|
|
54
|
+
exception = event.payload[:exception]
|
|
55
|
+
|
|
56
|
+
exception_backtrace = exception.backtrace&.first
|
|
57
|
+
exception_backtrace = exception_backtrace&.delete_prefix("#{Rails.root}/") if defined?(Rails.root) && Rails.root
|
|
58
|
+
|
|
59
|
+
info { "rescue_from handled #{exception.class} (#{exception.message}) - #{exception_backtrace}" }
|
|
60
|
+
end
|
|
61
|
+
subscribe_log_level :rescue_from_callback, :info
|
|
62
|
+
|
|
52
63
|
def send_file(event)
|
|
53
64
|
info { "Sent file #{event.payload[:path]} (#{event.duration.round(1)}ms)" }
|
|
54
65
|
end
|
|
@@ -56,6 +67,10 @@ module ActionController
|
|
|
56
67
|
|
|
57
68
|
def redirect_to(event)
|
|
58
69
|
info { "Redirected to #{event.payload[:location]}" }
|
|
70
|
+
|
|
71
|
+
if ActionDispatch.verbose_redirect_logs && (source = redirect_source_location)
|
|
72
|
+
info { "↳ #{source}" }
|
|
73
|
+
end
|
|
59
74
|
end
|
|
60
75
|
subscribe_log_level :redirect_to, :info
|
|
61
76
|
|
|
@@ -90,6 +105,10 @@ module ActionController
|
|
|
90
105
|
def logger
|
|
91
106
|
ActionController::Base.logger
|
|
92
107
|
end
|
|
108
|
+
|
|
109
|
+
def redirect_source_location
|
|
110
|
+
backtrace_cleaner.first_clean_frame
|
|
111
|
+
end
|
|
93
112
|
end
|
|
94
113
|
end
|
|
95
114
|
|
|
@@ -14,7 +14,7 @@ module ActionController # :nodoc:
|
|
|
14
14
|
# aren't reporting a user-agent header, will be allowed access.
|
|
15
15
|
#
|
|
16
16
|
# A browser that's blocked will by default be served the file in
|
|
17
|
-
# public/406-unsupported-browser.html with
|
|
17
|
+
# public/406-unsupported-browser.html with an HTTP status code of "406 Not
|
|
18
18
|
# Acceptable".
|
|
19
19
|
#
|
|
20
20
|
# In addition to specifically named browser versions, you can also pass
|
|
@@ -36,6 +36,16 @@ module ActionController # :nodoc:
|
|
|
36
36
|
# end
|
|
37
37
|
#
|
|
38
38
|
# class ApplicationController < ActionController::Base
|
|
39
|
+
# # Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has
|
|
40
|
+
# allow_browser versions: :modern, block: :handle_outdated_browser
|
|
41
|
+
#
|
|
42
|
+
# private
|
|
43
|
+
# def handle_outdated_browser
|
|
44
|
+
# render file: Rails.root.join("public/custom-error.html"), status: :not_acceptable
|
|
45
|
+
# end
|
|
46
|
+
# end
|
|
47
|
+
#
|
|
48
|
+
# class ApplicationController < ActionController::Base
|
|
39
49
|
# # All versions of Chrome and Opera will be allowed, but no versions of "internet explorer" (ie). Safari needs to be 16.4+ and Firefox 121+.
|
|
40
50
|
# allow_browser versions: { safari: 16.4, firefox: 121, ie: false }
|
|
41
51
|
# end
|
|
@@ -55,7 +65,7 @@ module ActionController # :nodoc:
|
|
|
55
65
|
|
|
56
66
|
if BrowserBlocker.new(request, versions: versions).blocked?
|
|
57
67
|
ActiveSupport::Notifications.instrument("browser_block.action_controller", request: request, versions: versions) do
|
|
58
|
-
instance_exec(&block)
|
|
68
|
+
block.is_a?(Symbol) ? send(block) : instance_exec(&block)
|
|
59
69
|
end
|
|
60
70
|
end
|
|
61
71
|
end
|
|
@@ -259,6 +259,9 @@ module ActionController
|
|
|
259
259
|
# `:stale_if_error`
|
|
260
260
|
# : Sets the value of the `stale-if-error` directive.
|
|
261
261
|
#
|
|
262
|
+
# `:immutable`
|
|
263
|
+
# : If true, adds the `immutable` directive.
|
|
264
|
+
#
|
|
262
265
|
#
|
|
263
266
|
# Any additional key-value pairs are concatenated as directives. For a list of
|
|
264
267
|
# supported `Cache-Control` directives, see the [article on
|
|
@@ -292,6 +295,7 @@ module ActionController
|
|
|
292
295
|
must_revalidate: options.delete(:must_revalidate),
|
|
293
296
|
stale_while_revalidate: options.delete(:stale_while_revalidate),
|
|
294
297
|
stale_if_error: options.delete(:stale_if_error),
|
|
298
|
+
immutable: options.delete(:immutable),
|
|
295
299
|
)
|
|
296
300
|
options.delete(:private)
|
|
297
301
|
|
|
@@ -315,7 +319,7 @@ module ActionController
|
|
|
315
319
|
# user's web browser. To allow proxies to cache the response, set `true` to
|
|
316
320
|
# indicate that they can serve the cached response to all users.
|
|
317
321
|
def http_cache_forever(public: false)
|
|
318
|
-
expires_in 100.years, public: public
|
|
322
|
+
expires_in 100.years, public: public, immutable: true
|
|
319
323
|
|
|
320
324
|
yield if stale?(etag: request.fullpath,
|
|
321
325
|
last_modified: Time.new(2011, 1, 1).utc,
|
|
@@ -328,6 +332,31 @@ module ActionController
|
|
|
328
332
|
response.cache_control.replace(no_store: true)
|
|
329
333
|
end
|
|
330
334
|
|
|
335
|
+
# Adds the `must-understand` directive to the `Cache-Control` header, which indicates
|
|
336
|
+
# that a cache MUST understand the semantics of the response status code that has been
|
|
337
|
+
# received, or discard the response.
|
|
338
|
+
#
|
|
339
|
+
# This is particularly useful when returning responses with new or uncommon
|
|
340
|
+
# status codes that might not be properly interpreted by older caches.
|
|
341
|
+
#
|
|
342
|
+
# #### Example
|
|
343
|
+
#
|
|
344
|
+
# def show
|
|
345
|
+
# @article = Article.find(params[:id])
|
|
346
|
+
#
|
|
347
|
+
# if @article.early_access?
|
|
348
|
+
# must_understand
|
|
349
|
+
# render status: 203 # Non-Authoritative Information
|
|
350
|
+
# else
|
|
351
|
+
# fresh_when @article
|
|
352
|
+
# end
|
|
353
|
+
# end
|
|
354
|
+
#
|
|
355
|
+
def must_understand
|
|
356
|
+
response.cache_control[:must_understand] = true
|
|
357
|
+
response.cache_control[:no_store] = true
|
|
358
|
+
end
|
|
359
|
+
|
|
331
360
|
private
|
|
332
361
|
def combine_etags(validator, options)
|
|
333
362
|
[validator, *etaggers.map { |etagger| instance_exec(options, &etagger) }].compact
|
|
@@ -28,7 +28,8 @@ module ActionController # :nodoc:
|
|
|
28
28
|
# `send_file(params[:path])` allows a malicious user to download any file on
|
|
29
29
|
# your server.
|
|
30
30
|
#
|
|
31
|
-
# Options:
|
|
31
|
+
# #### Options:
|
|
32
|
+
#
|
|
32
33
|
# * `:filename` - suggests a filename for the browser to use. Defaults to
|
|
33
34
|
# `File.basename(path)`.
|
|
34
35
|
# * `:type` - specifies an HTTP content type. You can specify either a string
|
|
@@ -90,7 +91,8 @@ module ActionController # :nodoc:
|
|
|
90
91
|
# inline data. You may also set the content type, the file name, and other
|
|
91
92
|
# things.
|
|
92
93
|
#
|
|
93
|
-
# Options:
|
|
94
|
+
# #### Options:
|
|
95
|
+
#
|
|
94
96
|
# * `:filename` - suggests a filename for the browser to use.
|
|
95
97
|
# * `:type` - specifies an HTTP content type. Defaults to
|
|
96
98
|
# `application/octet-stream`. You can specify either a string or a symbol
|
|
@@ -132,9 +134,7 @@ module ActionController # :nodoc:
|
|
|
132
134
|
raise ArgumentError, ":type option required" if content_type.nil?
|
|
133
135
|
|
|
134
136
|
if content_type.is_a?(Symbol)
|
|
135
|
-
|
|
136
|
-
raise ArgumentError, "Unknown MIME type #{options[:type]}" unless extension
|
|
137
|
-
self.content_type = extension
|
|
137
|
+
self.content_type = content_type
|
|
138
138
|
else
|
|
139
139
|
if !type_provided && options[:filename]
|
|
140
140
|
# If type wasn't provided, try guessing from file extension.
|
|
@@ -38,15 +38,12 @@ module ActionController # :nodoc:
|
|
|
38
38
|
define_method(type) do
|
|
39
39
|
request.flash[type]
|
|
40
40
|
end
|
|
41
|
+
private type
|
|
41
42
|
helper_method(type) if respond_to?(:helper_method)
|
|
42
43
|
|
|
43
44
|
self._flash_types += [type]
|
|
44
45
|
end
|
|
45
46
|
end
|
|
46
|
-
|
|
47
|
-
def action_methods # :nodoc:
|
|
48
|
-
@action_methods ||= super - _flash_types.map(&:to_s).to_set
|
|
49
|
-
end
|
|
50
47
|
end
|
|
51
48
|
|
|
52
49
|
private
|
|
@@ -25,6 +25,8 @@ module ActionController
|
|
|
25
25
|
raise ArgumentError, "#{status.inspect} is not a valid value for `status`."
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
raise ::AbstractController::DoubleRenderError if response_body
|
|
29
|
+
|
|
28
30
|
status ||= :ok
|
|
29
31
|
|
|
30
32
|
if options
|
|
@@ -41,7 +43,7 @@ module ActionController
|
|
|
41
43
|
|
|
42
44
|
if include_content?(response_code)
|
|
43
45
|
unless self.media_type
|
|
44
|
-
self.content_type = content_type || ((f = formats) && Mime[f.first]) ||
|
|
46
|
+
self.content_type = content_type || ((f = formats) && Mime[f.first]) || :html
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
response.charset = false
|
|
@@ -514,7 +514,7 @@ module ActionController
|
|
|
514
514
|
end
|
|
515
515
|
|
|
516
516
|
# This method takes an authorization body and splits up the key-value pairs by
|
|
517
|
-
# the standardized
|
|
517
|
+
# the standardized `,`, `;`, or `\t` delimiters defined in
|
|
518
518
|
# `AUTHN_PAIR_DELIMITERS`.
|
|
519
519
|
def raw_params(auth)
|
|
520
520
|
_raw_params = auth.sub(TOKEN_REGEX, "").split(AUTHN_PAIR_DELIMITERS).map(&:strip)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
# :markup: markdown
|
|
4
4
|
|
|
5
|
-
require "benchmark"
|
|
6
5
|
require "abstract_controller/logger"
|
|
7
6
|
|
|
8
7
|
module ActionController
|
|
@@ -29,7 +28,7 @@ module ActionController
|
|
|
29
28
|
def render(*)
|
|
30
29
|
render_output = nil
|
|
31
30
|
self.view_runtime = cleanup_view_runtime do
|
|
32
|
-
Benchmark.
|
|
31
|
+
ActiveSupport::Benchmark.realtime(:float_millisecond) { render_output = super }
|
|
33
32
|
end
|
|
34
33
|
render_output
|
|
35
34
|
end
|