actionpack 8.0.2 → 8.0.5.2
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 +162 -1
- data/README.rdoc +1 -1
- data/lib/abstract_controller/base.rb +1 -12
- data/lib/abstract_controller/collector.rb +1 -1
- data/lib/abstract_controller/helpers.rb +1 -1
- data/lib/action_controller/metal/live.rb +52 -11
- data/lib/action_controller/metal/redirecting.rb +2 -2
- data/lib/action_controller/metal/rendering.rb +10 -3
- data/lib/action_controller/metal/strong_parameters.rb +16 -8
- data/lib/action_controller/railtie.rb +5 -0
- data/lib/action_controller/renderer.rb +0 -1
- data/lib/action_dispatch/constants.rb +6 -0
- data/lib/action_dispatch/http/content_security_policy.rb +13 -1
- data/lib/action_dispatch/http/mime_negotiation.rb +19 -4
- data/lib/action_dispatch/http/response.rb +49 -14
- data/lib/action_dispatch/http/url.rb +2 -2
- data/lib/action_dispatch/journey/gtg/transition_table.rb +4 -4
- data/lib/action_dispatch/middleware/cookies.rb +16 -1
- data/lib/action_dispatch/middleware/debug_exceptions.rb +3 -1
- data/lib/action_dispatch/middleware/exception_wrapper.rb +3 -3
- data/lib/action_dispatch/middleware/public_exceptions.rb +5 -1
- data/lib/action_dispatch/middleware/session/abstract_store.rb +5 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +26 -3
- data/lib/action_dispatch/middleware/session/cookie_store.rb +0 -3
- data/lib/action_dispatch/routing/route_set.rb +1 -2
- data/lib/action_dispatch/routing/routes_proxy.rb +1 -0
- data/lib/action_dispatch/testing/assertion_response.rb +1 -1
- data/lib/action_dispatch/testing/integration.rb +7 -7
- data/lib/action_dispatch/testing/request_encoder.rb +9 -9
- data/lib/action_pack/gem_version.rb +2 -2
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b2135f13807ec1b81f58b821d0110dbb0ffc66eff77788b8fcec4ae9a74cf0e
|
|
4
|
+
data.tar.gz: 8f6f0efcbe740bd97d66e1fd463ac31fc71a13602b5c3716619050be4dab0363
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e382f4f372105c75eab3eb57e4bbc651eb75895b7f820f2a38bcdb5c1eef5ca2ea7291ac70751f843f2727956dce4b5f2ee875fc77e3f6356f645d411d49bb0
|
|
7
|
+
data.tar.gz: d27b6d307f70376ba5ad40a90a2e684203973c98e5bd9f975750a415aac7edd737d3a8e3c2f9af3b7d84a7528fbfb5aa4928cb606922b3d6d3d0c1f838533542
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,169 @@
|
|
|
1
|
-
## Rails 8.0.2 (
|
|
1
|
+
## Rails 8.0.5.2 (November 03, 2026) ##
|
|
2
|
+
|
|
3
|
+
* Apply `config.action_dispatch.cookies_same_site_protection` to every session
|
|
4
|
+
store.
|
|
5
|
+
|
|
6
|
+
`ActionDispatch::Session::CacheStore`, `MemCacheStore` and third-party
|
|
7
|
+
stores built on `AbstractStore` or the session mixins sent session cookies
|
|
8
|
+
with no `SameSite` attribute. Only `CookieStore` applied the configured
|
|
9
|
+
default.
|
|
10
|
+
|
|
11
|
+
[GHSA-gmj8-hvj3-49mw]
|
|
12
|
+
|
|
13
|
+
*Jean Boussier*
|
|
14
|
+
|
|
15
|
+
* Prevent `ActionController::Live` streams from blocking when a full buffer is
|
|
16
|
+
closed or aborted.
|
|
17
|
+
|
|
18
|
+
[GHSA-rwvh-fw6r-pwvp]
|
|
19
|
+
|
|
20
|
+
*Jeremy Daer*
|
|
21
|
+
|
|
22
|
+
* Set and extend the `Vary` header for rendered responses according to the
|
|
23
|
+
request headers used in format negotiation.
|
|
24
|
+
|
|
25
|
+
`Vary: Accept` was only added when the request carried a usable `Accept`
|
|
26
|
+
header. A response to a request without one, negotiated to HTML or
|
|
27
|
+
JavaScript, could be stored by a shared cache and served to later clients
|
|
28
|
+
that requested a different representation.
|
|
29
|
+
|
|
30
|
+
Responses now vary on `Accept` and `X-Requested-With` whenever the format is
|
|
31
|
+
not given by the URL. XHR requests without `Accept` also vary on
|
|
32
|
+
`Content-Type`, which Rails uses as a legacy format fallback. When
|
|
33
|
+
`config.action_dispatch.ignore_accept_header` is enabled, responses vary
|
|
34
|
+
only on `X-Requested-With`.
|
|
35
|
+
|
|
36
|
+
These fields are appended to an existing `Vary` value without duplicating
|
|
37
|
+
fields case-insensitively. `Vary: *` remains unchanged.
|
|
38
|
+
|
|
39
|
+
[GHSA-r9jg-fmfx-2gv6]
|
|
40
|
+
|
|
41
|
+
*Jeremy Daer*
|
|
42
|
+
|
|
43
|
+
* Skip writing a `CacheStore` session that another request deleted while this
|
|
44
|
+
one ran.
|
|
45
|
+
|
|
46
|
+
A request that loaded a session from `ActionDispatch::Session::CacheStore`
|
|
47
|
+
wrote it back when it finished, even after a concurrent `reset_session` or a
|
|
48
|
+
server-side delete had removed it, so the old session ID worked again.
|
|
49
|
+
|
|
50
|
+
[GHSA-2586-8ghr-69fj]
|
|
51
|
+
|
|
52
|
+
*Mike Dalessio*
|
|
53
|
+
|
|
54
|
+
* Don't write upgraded cookies to a response that skips the session.
|
|
55
|
+
|
|
56
|
+
Reading a signed or encrypted cookie written under a rotated secret, or in
|
|
57
|
+
the format a `:hybrid` serializer migrates from, writes it back in the
|
|
58
|
+
current format. That write ignored `request.session_options[:skip]`, so a
|
|
59
|
+
response that skips the session, such as the Active Storage proxy's
|
|
60
|
+
public, cacheable response, could still carry the session cookie in
|
|
61
|
+
`Set-Cookie`. Such a response now leaves the cookie unchanged, and a later
|
|
62
|
+
request that does not skip the session upgrades it. An application that
|
|
63
|
+
skips the session on every request no longer upgrades its signed or
|
|
64
|
+
encrypted cookies. Cookies the application sets are still written.
|
|
65
|
+
|
|
66
|
+
[GHSA-x6mj-8jx9-qhqv]
|
|
67
|
+
|
|
68
|
+
*Mike Dalessio*
|
|
69
|
+
|
|
70
|
+
* `ActionController::Parameters#each_key` returns `self` when given a block.
|
|
71
|
+
|
|
72
|
+
It returned the internal `ActiveSupport::HashWithIndifferentAccess`, which
|
|
73
|
+
does not respond to `permitted?`, so passing that return value to mass
|
|
74
|
+
assignment skipped the Strong Parameters check. `each`, `each_pair` and
|
|
75
|
+
`each_value` already return `self`.
|
|
76
|
+
|
|
77
|
+
Document that `ActionController::Parameters#as_json` returns every
|
|
78
|
+
parameter, permitted or not, in a hash that mass assignment does not check.
|
|
79
|
+
|
|
80
|
+
[GHSA-wm3x-v3qw-4jh3]
|
|
81
|
+
|
|
82
|
+
*Mike Dalessio*
|
|
83
|
+
|
|
84
|
+
## Rails 8.0.5.1 (July 29, 2026) ##
|
|
2
85
|
|
|
3
86
|
* No changes.
|
|
4
87
|
|
|
5
88
|
|
|
89
|
+
## Rails 8.0.5 (March 24, 2026) ##
|
|
90
|
+
|
|
91
|
+
* Add `config.action_controller.live_streaming_excluded_keys` to control execution state sharing in ActionController::Live.
|
|
92
|
+
|
|
93
|
+
When using ActionController::Live, actions are executed in a separate thread that shares
|
|
94
|
+
state from the parent thread. This new configuration allows applications to opt-out specific
|
|
95
|
+
state keys that should not be shared.
|
|
96
|
+
|
|
97
|
+
This is useful when streaming inside a `connected_to` block, where you may want
|
|
98
|
+
the streaming thread to use its own database connection context.
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
# config/application.rb
|
|
102
|
+
config.action_controller.live_streaming_excluded_keys = [:active_record_connected_to_stack]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
By default, all keys are shared.
|
|
106
|
+
|
|
107
|
+
*Eileen M. Uchitelle*
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## Rails 8.0.4.1 (March 23, 2026) ##
|
|
111
|
+
|
|
112
|
+
* No changes.
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Rails 8.0.4 (October 28, 2025) ##
|
|
116
|
+
|
|
117
|
+
* Submit test requests using `as: :html` with `Content-Type: x-www-form-urlencoded`
|
|
118
|
+
|
|
119
|
+
*Sean Doyle*
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## Rails 8.0.3 (September 22, 2025) ##
|
|
123
|
+
|
|
124
|
+
* URL helpers for engines mounted at the application root handle `SCRIPT_NAME` correctly.
|
|
125
|
+
|
|
126
|
+
Fixed an issue where `SCRIPT_NAME` is not applied to paths generated for routes in an engine
|
|
127
|
+
mounted at "/".
|
|
128
|
+
|
|
129
|
+
*Mike Dalessio*
|
|
130
|
+
|
|
131
|
+
* Fix `Rails.application.reload_routes!` from clearing almost all routes.
|
|
132
|
+
|
|
133
|
+
When calling `Rails.application.reload_routes!` inside a middleware of
|
|
134
|
+
a Rake task, it was possible under certain conditions that all routes would be cleared.
|
|
135
|
+
If ran inside a middleware, this would result in getting a 404 on most page you visit.
|
|
136
|
+
This issue was only happening in development.
|
|
137
|
+
|
|
138
|
+
*Edouard Chin*
|
|
139
|
+
|
|
140
|
+
* Address `rack 3.2` deprecations warnings.
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
warning: Status code :unprocessable_entity is deprecated and will be removed in a future version of Rack.
|
|
144
|
+
Please use :unprocessable_content instead.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Rails API will transparently convert one into the other for the foreseeable future.
|
|
148
|
+
|
|
149
|
+
*Earlopain*, *Jean Boussier*
|
|
150
|
+
|
|
151
|
+
* Support hash-source in Content Security Policy.
|
|
152
|
+
|
|
153
|
+
*madogiwa*
|
|
154
|
+
|
|
155
|
+
* Always return empty body for HEAD requests in `PublicExceptions` and
|
|
156
|
+
`DebugExceptions`.
|
|
157
|
+
|
|
158
|
+
This is required by `Rack::Lint` (per RFC9110).
|
|
159
|
+
|
|
160
|
+
*Hartley McGuire*
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
## Rails 8.0.2.1 (August 13, 2025) ##
|
|
164
|
+
|
|
165
|
+
* No changes.
|
|
166
|
+
|
|
6
167
|
## Rails 8.0.2 (March 12, 2025) ##
|
|
7
168
|
|
|
8
169
|
* Improve `with_routing` test helper to not rebuild the middleware stack.
|
data/README.rdoc
CHANGED
|
@@ -52,6 +52,6 @@ Bug reports for the Ruby on \Rails project can be filed here:
|
|
|
52
52
|
|
|
53
53
|
* https://github.com/rails/rails/issues
|
|
54
54
|
|
|
55
|
-
Feature requests should be discussed on the
|
|
55
|
+
Feature requests should be discussed on the rubyonrails-core forum here:
|
|
56
56
|
|
|
57
57
|
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
|
@@ -86,14 +86,10 @@ module AbstractController
|
|
|
86
86
|
controller.public_instance_methods(true) - methods
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
# A
|
|
89
|
+
# A `Set` of method names that should be considered actions. This includes all
|
|
90
90
|
# public instance methods on a controller, less any internal methods (see
|
|
91
91
|
# internal_methods), adding back in any methods that are internal, but still
|
|
92
92
|
# exist on the class itself.
|
|
93
|
-
#
|
|
94
|
-
# #### Returns
|
|
95
|
-
# * `Set` - A set of all methods that should be considered actions.
|
|
96
|
-
#
|
|
97
93
|
def action_methods
|
|
98
94
|
@action_methods ||= begin
|
|
99
95
|
# All public instance methods of this class, including ancestors except for
|
|
@@ -121,9 +117,6 @@ module AbstractController
|
|
|
121
117
|
#
|
|
122
118
|
# MyApp::MyPostsController.controller_path # => "my_app/my_posts"
|
|
123
119
|
#
|
|
124
|
-
# #### Returns
|
|
125
|
-
# * `String`
|
|
126
|
-
#
|
|
127
120
|
def controller_path
|
|
128
121
|
@controller_path ||= name.delete_suffix("Controller").underscore unless anonymous?
|
|
129
122
|
end
|
|
@@ -147,10 +140,6 @@ module AbstractController
|
|
|
147
140
|
# The actual method that is called is determined by calling #method_for_action.
|
|
148
141
|
# If no method can handle the action, then an AbstractController::ActionNotFound
|
|
149
142
|
# error is raised.
|
|
150
|
-
#
|
|
151
|
-
# #### Returns
|
|
152
|
-
# * `self`
|
|
153
|
-
#
|
|
154
143
|
def process(action, ...)
|
|
155
144
|
@_action_name = action.to_s
|
|
156
145
|
|
|
@@ -27,7 +27,7 @@ module AbstractController
|
|
|
27
27
|
def method_missing(symbol, ...)
|
|
28
28
|
unless mime_constant = Mime[symbol]
|
|
29
29
|
raise NoMethodError, "To respond to a custom format, register it as a MIME type first: " \
|
|
30
|
-
"https://guides.rubyonrails.org/
|
|
30
|
+
"https://guides.rubyonrails.org/action_controller_advanced_topics.html#restful-downloads. " \
|
|
31
31
|
"If you meant to respond to a variant like :tablet or :phone, not a custom format, " \
|
|
32
32
|
"be sure to nest your variant response within a format response: " \
|
|
33
33
|
"format.html { |html| html.tablet { ... } }"
|
|
@@ -90,7 +90,7 @@ module AbstractController
|
|
|
90
90
|
#--
|
|
91
91
|
# Implemented by Resolution#modules_for_helpers.
|
|
92
92
|
|
|
93
|
-
# :method:
|
|
93
|
+
# :method: all_helpers_from_path
|
|
94
94
|
# :call-seq: all_helpers_from_path(path)
|
|
95
95
|
#
|
|
96
96
|
# Returns a list of helper names in a given path.
|
|
@@ -53,9 +53,50 @@ module ActionController
|
|
|
53
53
|
# response.headers["Last-Modified"] = Time.now.httpdate # Add this line if your Rack version is 2.2.x
|
|
54
54
|
# ...
|
|
55
55
|
# end
|
|
56
|
+
#
|
|
57
|
+
# ## Streaming and Execution State
|
|
58
|
+
#
|
|
59
|
+
# When streaming, the action is executed in a separate thread. By default, this thread
|
|
60
|
+
# shares execution state from the parent thread.
|
|
61
|
+
#
|
|
62
|
+
# You can configure which execution state keys should be excluded from being shared
|
|
63
|
+
# using the `config.action_controller.live_streaming_excluded_keys` configuration:
|
|
64
|
+
#
|
|
65
|
+
# # config/application.rb
|
|
66
|
+
# config.action_controller.live_streaming_excluded_keys = [:active_record_connected_to_stack]
|
|
67
|
+
#
|
|
68
|
+
# This is useful when using ActionController::Live inside a `connected_to` block. For example,
|
|
69
|
+
# if the parent request is reading from a replica using `connected_to(role: :reading)`, you may
|
|
70
|
+
# want the streaming thread to use its own connection context instead of inheriting the read-only
|
|
71
|
+
# context:
|
|
72
|
+
#
|
|
73
|
+
# # Without configuration, streaming thread inherits read-only connection
|
|
74
|
+
# ActiveRecord::Base.connected_to(role: :reading) do
|
|
75
|
+
# @posts = Post.all
|
|
76
|
+
# render stream: true # Streaming thread cannot write to database
|
|
77
|
+
# end
|
|
78
|
+
#
|
|
79
|
+
# # With configuration, streaming thread gets fresh connection context
|
|
80
|
+
# # config.action_controller.live_streaming_excluded_keys = [:active_record_connected_to_stack]
|
|
81
|
+
# ActiveRecord::Base.connected_to(role: :reading) do
|
|
82
|
+
# @posts = Post.all
|
|
83
|
+
# render stream: true # Streaming thread can write to database if needed
|
|
84
|
+
# end
|
|
85
|
+
#
|
|
86
|
+
# Common keys you might want to exclude:
|
|
87
|
+
# - `:active_record_connected_to_stack` - Database connection routing and roles
|
|
88
|
+
# - `:active_record_prohibit_shard_swapping` - Shard swapping restrictions
|
|
89
|
+
#
|
|
90
|
+
# By default, no keys are excluded to maintain backward compatibility.
|
|
56
91
|
module Live
|
|
57
92
|
extend ActiveSupport::Concern
|
|
58
93
|
|
|
94
|
+
mattr_accessor :live_streaming_excluded_keys, default: []
|
|
95
|
+
|
|
96
|
+
included do
|
|
97
|
+
class_attribute :live_streaming_excluded_keys, instance_accessor: false, default: Live.live_streaming_excluded_keys
|
|
98
|
+
end
|
|
99
|
+
|
|
59
100
|
module ClassMethods
|
|
60
101
|
def make_response!(request)
|
|
61
102
|
if (request.get_header("SERVER_PROTOCOL") || request.get_header("HTTP_VERSION")) == "HTTP/1.0"
|
|
@@ -171,19 +212,17 @@ module ActionController
|
|
|
171
212
|
@ignore_disconnect = false
|
|
172
213
|
end
|
|
173
214
|
|
|
174
|
-
# ActionDispatch::Response delegates #to_ary to the internal
|
|
175
|
-
# ActionDispatch::Response::Buffer, defining #to_ary is an indicator that the
|
|
176
|
-
# response body can be buffered and/or cached by Rack middlewares, this is not
|
|
177
|
-
# the case for Live responses so we undefine it for this Buffer subclass.
|
|
178
|
-
undef_method :to_ary
|
|
179
|
-
|
|
180
215
|
def write(string)
|
|
181
216
|
unless @response.committed?
|
|
182
217
|
@response.headers["Cache-Control"] ||= "no-cache"
|
|
183
218
|
@response.delete_header "Content-Length"
|
|
184
219
|
end
|
|
185
220
|
|
|
186
|
-
|
|
221
|
+
begin
|
|
222
|
+
super
|
|
223
|
+
rescue ClosedQueueError
|
|
224
|
+
raise IOError, "closed stream" if connected?
|
|
225
|
+
end
|
|
187
226
|
|
|
188
227
|
unless connected?
|
|
189
228
|
@buf.clear
|
|
@@ -201,14 +240,14 @@ module ActionController
|
|
|
201
240
|
write string.end_with?("\n") ? string : "#{string}\n"
|
|
202
241
|
end
|
|
203
242
|
|
|
204
|
-
#
|
|
205
|
-
#
|
|
243
|
+
# Close the buffer; the producer/writing thread uses this to notify us that
|
|
244
|
+
# it's finished supplying content.
|
|
206
245
|
#
|
|
207
246
|
# See also #abort.
|
|
208
247
|
def close
|
|
209
248
|
synchronize do
|
|
210
249
|
super
|
|
211
|
-
@buf.
|
|
250
|
+
@buf.close
|
|
212
251
|
@cv.broadcast
|
|
213
252
|
end
|
|
214
253
|
end
|
|
@@ -220,7 +259,9 @@ module ActionController
|
|
|
220
259
|
def abort
|
|
221
260
|
synchronize do
|
|
222
261
|
@aborted = true
|
|
262
|
+
@buf.close
|
|
223
263
|
@buf.clear
|
|
264
|
+
@cv.broadcast
|
|
224
265
|
end
|
|
225
266
|
end
|
|
226
267
|
|
|
@@ -288,7 +329,7 @@ module ActionController
|
|
|
288
329
|
# Since we're processing the view in a different thread, copy the thread locals
|
|
289
330
|
# from the main thread to the child thread. :'(
|
|
290
331
|
locals.each { |k, v| t2[k] = v }
|
|
291
|
-
ActiveSupport::IsolatedExecutionState.share_with(t1)
|
|
332
|
+
ActiveSupport::IsolatedExecutionState.share_with(t1, except: self.class.live_streaming_excluded_keys)
|
|
292
333
|
|
|
293
334
|
begin
|
|
294
335
|
super(name)
|
|
@@ -212,9 +212,9 @@ module ActionController
|
|
|
212
212
|
|
|
213
213
|
def _extract_redirect_to_status(options, response_options)
|
|
214
214
|
if options.is_a?(Hash) && options.key?(:status)
|
|
215
|
-
|
|
215
|
+
ActionDispatch::Response.rack_status_code(options.delete(:status))
|
|
216
216
|
elsif response_options.key?(:status)
|
|
217
|
-
|
|
217
|
+
ActionDispatch::Response.rack_status_code(response_options[:status])
|
|
218
218
|
else
|
|
219
219
|
302
|
|
220
220
|
end
|
|
@@ -218,8 +218,15 @@ module ActionController
|
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
def _set_vary_header
|
|
221
|
-
if
|
|
222
|
-
response.headers["Vary"]
|
|
221
|
+
if request.should_apply_vary_header?
|
|
222
|
+
vary_headers = response.headers["Vary"].to_s.split(",").map(&:strip).reject(&:blank?)
|
|
223
|
+
|
|
224
|
+
unless vary_headers.include?("*")
|
|
225
|
+
request.vary_headers.each do |header|
|
|
226
|
+
vary_headers << header unless vary_headers.any? { |existing| existing.casecmp?(header) }
|
|
227
|
+
end
|
|
228
|
+
response.headers["Vary"] = vary_headers.join(", ")
|
|
229
|
+
end
|
|
223
230
|
end
|
|
224
231
|
end
|
|
225
232
|
|
|
@@ -232,7 +239,7 @@ module ActionController
|
|
|
232
239
|
end
|
|
233
240
|
|
|
234
241
|
if options[:status]
|
|
235
|
-
options[:status] =
|
|
242
|
+
options[:status] = ActionDispatch::Response.rack_status_code(options[:status])
|
|
236
243
|
end
|
|
237
244
|
|
|
238
245
|
super
|
|
@@ -197,15 +197,14 @@ module ActionController
|
|
|
197
197
|
# as_json(options=nil)
|
|
198
198
|
#
|
|
199
199
|
# Returns a hash that can be used as the JSON representation for the parameters.
|
|
200
|
-
|
|
201
|
-
##
|
|
202
|
-
# :method: each_key
|
|
203
200
|
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
201
|
+
# Like `#to_unsafe_h`, the hash holds every parameter, permitted or not, and
|
|
202
|
+
# mass assignment does not check it. Do not pass it to a model.
|
|
206
203
|
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
204
|
+
# params = ActionController::Parameters.new(name: "Bob", admin: true)
|
|
205
|
+
# params.as_json # => {"name" => "Bob", "admin" => true}
|
|
206
|
+
# User.new(params) # => ActiveModel::ForbiddenAttributesError
|
|
207
|
+
# User.new(params.as_json) # => #<User name: "Bob", admin: true>
|
|
209
208
|
|
|
210
209
|
##
|
|
211
210
|
# :method: empty?
|
|
@@ -248,7 +247,7 @@ module ActionController
|
|
|
248
247
|
# Returns the content of the parameters as a string.
|
|
249
248
|
|
|
250
249
|
delegate :keys, :empty?, :exclude?, :include?,
|
|
251
|
-
:as_json, :to_s,
|
|
250
|
+
:as_json, :to_s, to: :@parameters
|
|
252
251
|
|
|
253
252
|
alias_method :has_key?, :include?
|
|
254
253
|
alias_method :key?, :include?
|
|
@@ -420,6 +419,15 @@ module ActionController
|
|
|
420
419
|
self
|
|
421
420
|
end
|
|
422
421
|
|
|
422
|
+
# Calls block once for each key in the parameters, passing the key. If no block
|
|
423
|
+
# is given, an enumerator is returned instead.
|
|
424
|
+
def each_key(&block)
|
|
425
|
+
return to_enum(:each_key) unless block_given?
|
|
426
|
+
@parameters.each_key(&block)
|
|
427
|
+
|
|
428
|
+
self
|
|
429
|
+
end
|
|
430
|
+
|
|
423
431
|
# Returns a new array of the values of the parameters.
|
|
424
432
|
def values
|
|
425
433
|
to_enum(:each_value).to_a
|
|
@@ -31,6 +31,10 @@ module ActionController
|
|
|
31
31
|
ActionController::Helpers.helpers_path = app.helpers_paths
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
initializer "action_controller.live_streaming_excluded_keys" do |app|
|
|
35
|
+
ActionController::Live.live_streaming_excluded_keys = app.config.action_controller.live_streaming_excluded_keys
|
|
36
|
+
end
|
|
37
|
+
|
|
34
38
|
initializer "action_controller.parameters_config" do |app|
|
|
35
39
|
options = app.config.action_controller
|
|
36
40
|
|
|
@@ -80,6 +84,7 @@ module ActionController
|
|
|
80
84
|
:action_on_unpermitted_parameters,
|
|
81
85
|
:always_permitted_parameters,
|
|
82
86
|
:wrap_parameters_by_default,
|
|
87
|
+
:live_streaming_excluded_keys
|
|
83
88
|
)
|
|
84
89
|
|
|
85
90
|
filtered_options.each do |k, v|
|
|
@@ -96,7 +96,6 @@ module ActionController
|
|
|
96
96
|
# * `:script_name` - The portion of the incoming request's URL path that
|
|
97
97
|
# corresponds to the application. Converts to Rack's `SCRIPT_NAME`.
|
|
98
98
|
# * `:input` - The input stream. Converts to Rack's `rack.input`.
|
|
99
|
-
#
|
|
100
99
|
# * `defaults` - Default values for the Rack env. Entries are specified in the
|
|
101
100
|
# same format as `env`. `env` will be merged on top of these values.
|
|
102
101
|
# `defaults` will be retained when calling #new on a renderer instance.
|
|
@@ -30,5 +30,11 @@ module ActionDispatch
|
|
|
30
30
|
SERVER_TIMING = "server-timing"
|
|
31
31
|
STRICT_TRANSPORT_SECURITY = "strict-transport-security"
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3.1")
|
|
35
|
+
UNPROCESSABLE_CONTENT = :unprocessable_entity
|
|
36
|
+
else
|
|
37
|
+
UNPROCESSABLE_CONTENT = :unprocessable_content
|
|
38
|
+
end
|
|
33
39
|
end
|
|
34
40
|
end
|
|
@@ -171,6 +171,8 @@ module ActionDispatch # :nodoc:
|
|
|
171
171
|
worker_src: "worker-src"
|
|
172
172
|
}.freeze
|
|
173
173
|
|
|
174
|
+
HASH_SOURCE_ALGORITHM_PREFIXES = ["sha256-", "sha384-", "sha512-"].freeze
|
|
175
|
+
|
|
174
176
|
DEFAULT_NONCE_DIRECTIVES = %w[script-src style-src].freeze
|
|
175
177
|
|
|
176
178
|
private_constant :MAPPINGS, :DIRECTIVES, :DEFAULT_NONCE_DIRECTIVES
|
|
@@ -305,7 +307,13 @@ module ActionDispatch # :nodoc:
|
|
|
305
307
|
case source
|
|
306
308
|
when Symbol
|
|
307
309
|
apply_mapping(source)
|
|
308
|
-
when String
|
|
310
|
+
when String
|
|
311
|
+
if hash_source?(source)
|
|
312
|
+
"'#{source}'"
|
|
313
|
+
else
|
|
314
|
+
source
|
|
315
|
+
end
|
|
316
|
+
when Proc
|
|
309
317
|
source
|
|
310
318
|
else
|
|
311
319
|
raise ArgumentError, "Invalid content security policy source: #{source.inspect}"
|
|
@@ -374,5 +382,9 @@ module ActionDispatch # :nodoc:
|
|
|
374
382
|
def nonce_directive?(directive, nonce_directives)
|
|
375
383
|
nonce_directives.include?(directive)
|
|
376
384
|
end
|
|
385
|
+
|
|
386
|
+
def hash_source?(source)
|
|
387
|
+
source.start_with?(*HASH_SOURCE_ALGORITHM_PREFIXES)
|
|
388
|
+
end
|
|
377
389
|
end
|
|
378
390
|
end
|
|
@@ -56,9 +56,14 @@ module ActionDispatch
|
|
|
56
56
|
|
|
57
57
|
# Returns the MIME type for the format used in the request.
|
|
58
58
|
#
|
|
59
|
-
# GET /posts/5.xml
|
|
60
|
-
#
|
|
61
|
-
#
|
|
59
|
+
# # GET /posts/5.xml
|
|
60
|
+
# request.format # => Mime[:xml]
|
|
61
|
+
#
|
|
62
|
+
# # GET /posts/5.xhtml
|
|
63
|
+
# request.format # => Mime[:html]
|
|
64
|
+
#
|
|
65
|
+
# # GET /posts/5
|
|
66
|
+
# request.format # => Mime[:html] or Mime[:js], or request.accepts.first
|
|
62
67
|
#
|
|
63
68
|
def format(_view_path = nil)
|
|
64
69
|
formats.first || Mime::NullType.instance
|
|
@@ -153,7 +158,17 @@ module ActionDispatch
|
|
|
153
158
|
end
|
|
154
159
|
|
|
155
160
|
def should_apply_vary_header?
|
|
156
|
-
!params_readable?
|
|
161
|
+
!params_readable?
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def vary_headers # :nodoc:
|
|
165
|
+
if use_accept_header
|
|
166
|
+
headers = ["Accept", "X-Requested-With"]
|
|
167
|
+
headers.insert(1, "Content-Type") if xhr? && accept.blank?
|
|
168
|
+
headers
|
|
169
|
+
else
|
|
170
|
+
["X-Requested-With"]
|
|
171
|
+
end
|
|
157
172
|
end
|
|
158
173
|
|
|
159
174
|
private
|
|
@@ -46,6 +46,20 @@ module ActionDispatch # :nodoc:
|
|
|
46
46
|
Headers = ::Rack::Utils::HeaderHash
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
class << self
|
|
50
|
+
if ActionDispatch::Constants::UNPROCESSABLE_CONTENT == :unprocessable_content
|
|
51
|
+
def rack_status_code(status) # :nodoc:
|
|
52
|
+
status = :unprocessable_content if status == :unprocessable_entity
|
|
53
|
+
Rack::Utils.status_code(status)
|
|
54
|
+
end
|
|
55
|
+
else
|
|
56
|
+
def rack_status_code(status) # :nodoc:
|
|
57
|
+
status = :unprocessable_entity if status == :unprocessable_content
|
|
58
|
+
Rack::Utils.status_code(status)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
49
63
|
# To be deprecated:
|
|
50
64
|
Header = Headers
|
|
51
65
|
|
|
@@ -105,10 +119,22 @@ module ActionDispatch # :nodoc:
|
|
|
105
119
|
@str_body = nil
|
|
106
120
|
end
|
|
107
121
|
|
|
122
|
+
BODY_METHODS = { to_ary: true }
|
|
123
|
+
|
|
124
|
+
def respond_to?(method, include_private = false)
|
|
125
|
+
if BODY_METHODS.key?(method)
|
|
126
|
+
@buf.respond_to?(method)
|
|
127
|
+
else
|
|
128
|
+
super
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
108
132
|
def to_ary
|
|
109
|
-
@
|
|
110
|
-
|
|
111
|
-
|
|
133
|
+
if @str_body
|
|
134
|
+
[body]
|
|
135
|
+
else
|
|
136
|
+
@buf = @buf.to_ary
|
|
137
|
+
end
|
|
112
138
|
end
|
|
113
139
|
|
|
114
140
|
def body
|
|
@@ -245,7 +271,7 @@ module ActionDispatch # :nodoc:
|
|
|
245
271
|
|
|
246
272
|
# Sets the HTTP status code.
|
|
247
273
|
def status=(status)
|
|
248
|
-
@status =
|
|
274
|
+
@status = Response.rack_status_code(status)
|
|
249
275
|
end
|
|
250
276
|
|
|
251
277
|
# Sets the HTTP response's content MIME type. For example, in the controller you
|
|
@@ -328,7 +354,13 @@ module ActionDispatch # :nodoc:
|
|
|
328
354
|
# Returns the content of the response as a string. This contains the contents of
|
|
329
355
|
# any calls to `render`.
|
|
330
356
|
def body
|
|
331
|
-
@stream.
|
|
357
|
+
if @stream.respond_to?(:to_ary)
|
|
358
|
+
@stream.to_ary.join
|
|
359
|
+
elsif @stream.respond_to?(:body)
|
|
360
|
+
@stream.body
|
|
361
|
+
else
|
|
362
|
+
@stream
|
|
363
|
+
end
|
|
332
364
|
end
|
|
333
365
|
|
|
334
366
|
def write(string)
|
|
@@ -337,11 +369,16 @@ module ActionDispatch # :nodoc:
|
|
|
337
369
|
|
|
338
370
|
# Allows you to manually set or override the response body.
|
|
339
371
|
def body=(body)
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
372
|
+
# Prevent ActionController::Metal::Live::Response from committing the response prematurely.
|
|
373
|
+
synchronize do
|
|
374
|
+
if body.respond_to?(:to_str)
|
|
375
|
+
@stream = build_buffer(self, [body])
|
|
376
|
+
elsif body.respond_to?(:to_path)
|
|
377
|
+
@stream = body
|
|
378
|
+
elsif body.respond_to?(:to_ary)
|
|
379
|
+
@stream = build_buffer(self, body)
|
|
380
|
+
else
|
|
381
|
+
@stream = body
|
|
345
382
|
end
|
|
346
383
|
end
|
|
347
384
|
end
|
|
@@ -482,10 +519,6 @@ module ActionDispatch # :nodoc:
|
|
|
482
519
|
Buffer.new response, body
|
|
483
520
|
end
|
|
484
521
|
|
|
485
|
-
def munge_body_object(body)
|
|
486
|
-
body.respond_to?(:each) ? body : [body]
|
|
487
|
-
end
|
|
488
|
-
|
|
489
522
|
def assign_default_content_type_and_charset!
|
|
490
523
|
return if media_type
|
|
491
524
|
|
|
@@ -499,6 +532,8 @@ module ActionDispatch # :nodoc:
|
|
|
499
532
|
@response = response
|
|
500
533
|
end
|
|
501
534
|
|
|
535
|
+
attr :response
|
|
536
|
+
|
|
502
537
|
def close
|
|
503
538
|
# Rack "close" maps to Response#abort, and **not** Response#close (which is used
|
|
504
539
|
# when the controller's finished writing)
|
|
@@ -272,7 +272,7 @@ module ActionDispatch
|
|
|
272
272
|
end
|
|
273
273
|
end
|
|
274
274
|
|
|
275
|
-
# Returns whether this request is using the standard port
|
|
275
|
+
# Returns whether this request is using the standard port.
|
|
276
276
|
#
|
|
277
277
|
# req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:80'
|
|
278
278
|
# req.standard_port? # => true
|
|
@@ -307,7 +307,7 @@ module ActionDispatch
|
|
|
307
307
|
standard_port? ? "" : ":#{port}"
|
|
308
308
|
end
|
|
309
309
|
|
|
310
|
-
# Returns the requested port, such as 8080, based on SERVER_PORT
|
|
310
|
+
# Returns the requested port, such as 8080, based on SERVER_PORT.
|
|
311
311
|
#
|
|
312
312
|
# req = ActionDispatch::Request.new 'SERVER_PORT' => '80'
|
|
313
313
|
# req.server_port # => 80
|
|
@@ -107,10 +107,10 @@ module ActionDispatch
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
{
|
|
110
|
-
regexp_states: simple_regexp,
|
|
111
|
-
string_states: @string_states,
|
|
112
|
-
stdparam_states: @stdparam_states,
|
|
113
|
-
accepting: @accepting
|
|
110
|
+
regexp_states: simple_regexp.stringify_keys,
|
|
111
|
+
string_states: @string_states.stringify_keys,
|
|
112
|
+
stdparam_states: @stdparam_states.stringify_keys,
|
|
113
|
+
accepting: @accepting.stringify_keys
|
|
114
114
|
}
|
|
115
115
|
end
|
|
116
116
|
|
|
@@ -324,6 +324,7 @@ module ActionDispatch
|
|
|
324
324
|
def initialize(request)
|
|
325
325
|
@set_cookies = {}
|
|
326
326
|
@delete_cookies = {}
|
|
327
|
+
@upgraded_cookies = Set.new
|
|
327
328
|
@request = request
|
|
328
329
|
@cookies = {}
|
|
329
330
|
@committed = false
|
|
@@ -386,6 +387,7 @@ module ActionDispatch
|
|
|
386
387
|
end
|
|
387
388
|
|
|
388
389
|
handle_options(options)
|
|
390
|
+
@upgraded_cookies.delete(name.to_s)
|
|
389
391
|
|
|
390
392
|
if @cookies[name.to_s] != value || options[:expires]
|
|
391
393
|
@cookies[name.to_s] = value
|
|
@@ -426,8 +428,14 @@ module ActionDispatch
|
|
|
426
428
|
@cookies.each_key { |k| delete(k, options) }
|
|
427
429
|
end
|
|
428
430
|
|
|
431
|
+
def upgraded(name)
|
|
432
|
+
@upgraded_cookies << name.to_s
|
|
433
|
+
end
|
|
434
|
+
|
|
429
435
|
def write(response)
|
|
430
436
|
@set_cookies.each do |name, value|
|
|
437
|
+
next if @upgraded_cookies.include?(name) && request.session_options[:skip]
|
|
438
|
+
|
|
431
439
|
if write_cookie?(value)
|
|
432
440
|
response.set_cookie(name, value)
|
|
433
441
|
end
|
|
@@ -533,6 +541,10 @@ module ActionDispatch
|
|
|
533
541
|
@parent_jar[name] = options
|
|
534
542
|
end
|
|
535
543
|
|
|
544
|
+
def upgraded(name)
|
|
545
|
+
@parent_jar.upgraded(name)
|
|
546
|
+
end
|
|
547
|
+
|
|
536
548
|
protected
|
|
537
549
|
def request; @parent_jar.request; end
|
|
538
550
|
|
|
@@ -599,7 +611,10 @@ module ActionDispatch
|
|
|
599
611
|
return
|
|
600
612
|
end
|
|
601
613
|
|
|
602
|
-
|
|
614
|
+
if force_reserialize || reserialize?(dumped)
|
|
615
|
+
self[name] = { value: value }
|
|
616
|
+
upgraded(name)
|
|
617
|
+
end
|
|
603
618
|
|
|
604
619
|
value
|
|
605
620
|
end
|
|
@@ -65,7 +65,9 @@ module ActionDispatch
|
|
|
65
65
|
content_type = Mime[:text]
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
if
|
|
68
|
+
if request.raw_request_method == "HEAD"
|
|
69
|
+
render(wrapper.status_code, "", content_type)
|
|
70
|
+
elsif api_request?(content_type)
|
|
69
71
|
render_for_api_request(content_type, wrapper)
|
|
70
72
|
else
|
|
71
73
|
render_for_browser_request(request, wrapper)
|
|
@@ -18,8 +18,8 @@ module ActionDispatch
|
|
|
18
18
|
"ActionController::UnknownFormat" => :not_acceptable,
|
|
19
19
|
"ActionDispatch::Http::MimeNegotiation::InvalidType" => :not_acceptable,
|
|
20
20
|
"ActionController::MissingExactTemplate" => :not_acceptable,
|
|
21
|
-
"ActionController::InvalidAuthenticityToken" =>
|
|
22
|
-
"ActionController::InvalidCrossOriginRequest" =>
|
|
21
|
+
"ActionController::InvalidAuthenticityToken" => ActionDispatch::Constants::UNPROCESSABLE_CONTENT,
|
|
22
|
+
"ActionController::InvalidCrossOriginRequest" => ActionDispatch::Constants::UNPROCESSABLE_CONTENT,
|
|
23
23
|
"ActionDispatch::Http::Parameters::ParseError" => :bad_request,
|
|
24
24
|
"ActionController::BadRequest" => :bad_request,
|
|
25
25
|
"ActionController::ParameterMissing" => :bad_request,
|
|
@@ -173,7 +173,7 @@ module ActionDispatch
|
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
def self.status_code_for_exception(class_name)
|
|
176
|
-
|
|
176
|
+
ActionDispatch::Response.rack_status_code(@@rescue_responses[class_name])
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
def show?(request)
|
|
@@ -32,7 +32,11 @@ module ActionDispatch
|
|
|
32
32
|
end
|
|
33
33
|
body = { status: status, error: Rack::Utils::HTTP_STATUS_CODES.fetch(status, Rack::Utils::HTTP_STATUS_CODES[500]) }
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
if env["action_dispatch.original_request_method"] == "HEAD"
|
|
36
|
+
render_format(status, content_type, "")
|
|
37
|
+
else
|
|
38
|
+
render(status, content_type, body)
|
|
39
|
+
end
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
private
|
|
@@ -20,8 +20,13 @@ module ActionDispatch
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
module Compatibility
|
|
23
|
+
DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc:
|
|
24
|
+
|
|
23
25
|
def initialize(app, options = {})
|
|
24
26
|
options[:key] ||= "_session_id"
|
|
27
|
+
unless options.key?(:same_site) || self.class::DEFAULT_OPTIONS.key?(:same_site)
|
|
28
|
+
options = options.merge(same_site: DEFAULT_SAME_SITE)
|
|
29
|
+
end
|
|
25
30
|
super
|
|
26
31
|
end
|
|
27
32
|
|
|
@@ -20,6 +20,8 @@ module ActionDispatch
|
|
|
20
20
|
# is used.
|
|
21
21
|
#
|
|
22
22
|
class CacheStore < AbstractSecureStore
|
|
23
|
+
LOADED_SESSION_ID = "action_dispatch.session.cache_store.loaded_session_id" # :nodoc:
|
|
24
|
+
|
|
23
25
|
def initialize(app, options = {})
|
|
24
26
|
@cache = options[:cache] || Rails.cache
|
|
25
27
|
options[:expire_after] ||= @cache.options[:expires_in]
|
|
@@ -27,17 +29,20 @@ module ActionDispatch
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
# Get a session from the cache.
|
|
30
|
-
def find_session(
|
|
31
|
-
|
|
32
|
+
def find_session(req, sid)
|
|
33
|
+
if sid && (session = get_session_with_fallback(sid))
|
|
34
|
+
req.set_header(LOADED_SESSION_ID, sid.private_id)
|
|
35
|
+
else
|
|
32
36
|
sid, session = generate_sid, {}
|
|
33
37
|
end
|
|
34
38
|
[sid, session]
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
# Set a session in the cache.
|
|
38
|
-
def write_session(
|
|
42
|
+
def write_session(req, sid, session, options)
|
|
39
43
|
key = cache_key(sid.private_id)
|
|
40
44
|
if session
|
|
45
|
+
return false if destroyed_since_loaded?(req, sid)
|
|
41
46
|
@cache.write(key, session, expires_in: options[:expire_after])
|
|
42
47
|
else
|
|
43
48
|
@cache.delete(key)
|
|
@@ -61,6 +66,24 @@ module ActionDispatch
|
|
|
61
66
|
def get_session_with_fallback(sid)
|
|
62
67
|
@cache.read(cache_key(sid.private_id)) || @cache.read(cache_key(sid.public_id))
|
|
63
68
|
end
|
|
69
|
+
|
|
70
|
+
# Writing back a session that another request deleted, such as on logout,
|
|
71
|
+
# would restore it.
|
|
72
|
+
def destroyed_since_loaded?(req, sid)
|
|
73
|
+
req.get_header(LOADED_SESSION_ID) == sid.private_id &&
|
|
74
|
+
!exist_in_backend?(cache_key(sid.private_id)) &&
|
|
75
|
+
!exist_in_backend?(cache_key(sid.public_id))
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# The request-local cache still holds the entry this request loaded, so
|
|
79
|
+
# a lookup through it cannot see a delete made by another request.
|
|
80
|
+
def exist_in_backend?(key)
|
|
81
|
+
if @cache.respond_to?(:with_local_cache)
|
|
82
|
+
@cache.with_local_cache { @cache.exist?(key) }
|
|
83
|
+
else
|
|
84
|
+
@cache.exist?(key)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
64
87
|
end
|
|
65
88
|
end
|
|
66
89
|
end
|
|
@@ -59,11 +59,8 @@ module ActionDispatch
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc:
|
|
63
|
-
|
|
64
62
|
def initialize(app, options = {})
|
|
65
63
|
options[:cookie_only] = true
|
|
66
|
-
options[:same_site] = DEFAULT_SAME_SITE if !options.key?(:same_site)
|
|
67
64
|
super
|
|
68
65
|
end
|
|
69
66
|
|
|
@@ -29,7 +29,7 @@ module ActionDispatch
|
|
|
29
29
|
def from_requirements(requirements)
|
|
30
30
|
routes.find { |route| route.requirements == requirements }
|
|
31
31
|
end
|
|
32
|
-
# :
|
|
32
|
+
# :enddoc:
|
|
33
33
|
|
|
34
34
|
# Since the router holds references to many parts of the system like engines,
|
|
35
35
|
# controllers and the application itself, inspecting the route set can actually
|
|
@@ -953,6 +953,5 @@ module ActionDispatch
|
|
|
953
953
|
end
|
|
954
954
|
end
|
|
955
955
|
end
|
|
956
|
-
# :startdoc:
|
|
957
956
|
end
|
|
958
957
|
end
|
|
@@ -54,6 +54,7 @@ module ActionDispatch
|
|
|
54
54
|
# dependent part.
|
|
55
55
|
def merge_script_names(previous_script_name, new_script_name)
|
|
56
56
|
return new_script_name unless previous_script_name
|
|
57
|
+
new_script_name = new_script_name.chomp("/")
|
|
57
58
|
|
|
58
59
|
resolved_parts = new_script_name.count("/")
|
|
59
60
|
previous_parts = previous_script_name.count("/")
|
|
@@ -184,7 +184,7 @@ module ActionDispatch
|
|
|
184
184
|
# Returns `true` if the session is mimicking a secure HTTPS request.
|
|
185
185
|
#
|
|
186
186
|
# if session.https?
|
|
187
|
-
# ...
|
|
187
|
+
# # ...
|
|
188
188
|
# end
|
|
189
189
|
def https?
|
|
190
190
|
@https
|
|
@@ -203,7 +203,7 @@ module ActionDispatch
|
|
|
203
203
|
# * `env`: Additional env to pass, as a Hash. The headers will be merged into
|
|
204
204
|
# the Rack env hash.
|
|
205
205
|
# * `xhr`: Set to `true` if you want to make an Ajax request. Adds request
|
|
206
|
-
# headers characteristic of XMLHttpRequest e.g. HTTP_X_REQUESTED_WITH
|
|
206
|
+
# headers characteristic of `XMLHttpRequest`, e.g. `HTTP_X_REQUESTED_WITH`. The
|
|
207
207
|
# headers will be merged into the Rack env hash.
|
|
208
208
|
# * `as`: Used for encoding the request with different content type. Supports
|
|
209
209
|
# `:json` by default and will set the appropriate request headers. The
|
|
@@ -218,9 +218,10 @@ module ActionDispatch
|
|
|
218
218
|
# This method returns the response status, after performing the request.
|
|
219
219
|
# Furthermore, if this method was called from an ActionDispatch::IntegrationTest
|
|
220
220
|
# object, then that object's `@response` instance variable will point to a
|
|
221
|
-
#
|
|
221
|
+
# ActionDispatch::TestResponse object which one can use to inspect the details of the response.
|
|
222
222
|
#
|
|
223
223
|
# Example:
|
|
224
|
+
#
|
|
224
225
|
# process :get, '/author', params: { since: 201501011400 }
|
|
225
226
|
def process(method, path, params: nil, headers: nil, env: nil, xhr: false, as: nil)
|
|
226
227
|
request_encoder = RequestEncoder.encoder(as)
|
|
@@ -604,9 +605,8 @@ module ActionDispatch
|
|
|
604
605
|
# end
|
|
605
606
|
# end
|
|
606
607
|
#
|
|
607
|
-
# See the [request helpers documentation]
|
|
608
|
-
#
|
|
609
|
-
# on how to use `get`, etc.
|
|
608
|
+
# See the [request helpers documentation](rdoc-ref:ActionDispatch::Integration::RequestHelpers)
|
|
609
|
+
# for help on how to use `get`, etc.
|
|
610
610
|
#
|
|
611
611
|
# ### Changing the request encoding
|
|
612
612
|
#
|
|
@@ -622,7 +622,7 @@ module ActionDispatch
|
|
|
622
622
|
# end
|
|
623
623
|
#
|
|
624
624
|
# assert_response :success
|
|
625
|
-
# assert_equal({ id
|
|
625
|
+
# assert_equal({ "id" => Article.last.id, "title" => "Ahoy!" }, response.parsed_body)
|
|
626
626
|
# end
|
|
627
627
|
# end
|
|
628
628
|
#
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# :markup: markdown
|
|
4
4
|
|
|
5
5
|
require "nokogiri"
|
|
6
|
+
require "action_dispatch/http/mime_type"
|
|
6
7
|
|
|
7
8
|
module ActionDispatch
|
|
8
9
|
class RequestEncoder # :nodoc:
|
|
@@ -15,9 +16,9 @@ module ActionDispatch
|
|
|
15
16
|
|
|
16
17
|
@encoders = { identity: IdentityEncoder.new }
|
|
17
18
|
|
|
18
|
-
attr_reader :response_parser
|
|
19
|
+
attr_reader :response_parser, :content_type
|
|
19
20
|
|
|
20
|
-
def initialize(mime_name, param_encoder, response_parser)
|
|
21
|
+
def initialize(mime_name, param_encoder, response_parser, content_type)
|
|
21
22
|
@mime = Mime[mime_name]
|
|
22
23
|
|
|
23
24
|
unless @mime
|
|
@@ -27,10 +28,7 @@ module ActionDispatch
|
|
|
27
28
|
|
|
28
29
|
@response_parser = response_parser || -> body { body }
|
|
29
30
|
@param_encoder = param_encoder || :"to_#{@mime.symbol}".to_proc
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def content_type
|
|
33
|
-
@mime.to_s
|
|
31
|
+
@content_type = content_type || @mime.to_s
|
|
34
32
|
end
|
|
35
33
|
|
|
36
34
|
def accept_header
|
|
@@ -50,11 +48,13 @@ module ActionDispatch
|
|
|
50
48
|
@encoders[name] || @encoders[:identity]
|
|
51
49
|
end
|
|
52
50
|
|
|
53
|
-
def self.register_encoder(mime_name, param_encoder: nil, response_parser: nil)
|
|
54
|
-
@encoders[mime_name] = new(mime_name, param_encoder, response_parser)
|
|
51
|
+
def self.register_encoder(mime_name, param_encoder: nil, response_parser: nil, content_type: nil)
|
|
52
|
+
@encoders[mime_name] = new(mime_name, param_encoder, response_parser, content_type)
|
|
55
53
|
end
|
|
56
54
|
|
|
57
|
-
register_encoder :html, response_parser: -> body { Rails::Dom::Testing.html_document.parse(body) }
|
|
55
|
+
register_encoder :html, response_parser: -> body { Rails::Dom::Testing.html_document.parse(body) },
|
|
56
|
+
param_encoder: -> param { param },
|
|
57
|
+
content_type: Mime[:url_encoded_form].to_s
|
|
58
58
|
register_encoder :json, response_parser: -> body { JSON.parse(body, object_class: ActiveSupport::HashWithIndifferentAccess) }
|
|
59
59
|
end
|
|
60
60
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: actionpack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.0.2
|
|
4
|
+
version: 8.0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 8.0.2
|
|
18
|
+
version: 8.0.5.2
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 8.0.2
|
|
25
|
+
version: 8.0.5.2
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: nokogiri
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -127,28 +127,28 @@ dependencies:
|
|
|
127
127
|
requirements:
|
|
128
128
|
- - '='
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: 8.0.2
|
|
130
|
+
version: 8.0.5.2
|
|
131
131
|
type: :runtime
|
|
132
132
|
prerelease: false
|
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
134
134
|
requirements:
|
|
135
135
|
- - '='
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: 8.0.2
|
|
137
|
+
version: 8.0.5.2
|
|
138
138
|
- !ruby/object:Gem::Dependency
|
|
139
139
|
name: activemodel
|
|
140
140
|
requirement: !ruby/object:Gem::Requirement
|
|
141
141
|
requirements:
|
|
142
142
|
- - '='
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: 8.0.2
|
|
144
|
+
version: 8.0.5.2
|
|
145
145
|
type: :development
|
|
146
146
|
prerelease: false
|
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements:
|
|
149
149
|
- - '='
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: 8.0.2
|
|
151
|
+
version: 8.0.5.2
|
|
152
152
|
description: Web apps on Rails. Simple, battle-tested conventions for building and
|
|
153
153
|
testing MVC web applications. Works with any Rack-compatible server.
|
|
154
154
|
email: david@loudthinking.com
|
|
@@ -349,10 +349,10 @@ licenses:
|
|
|
349
349
|
- MIT
|
|
350
350
|
metadata:
|
|
351
351
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
|
352
|
-
changelog_uri: https://github.com/rails/rails/blob/v8.0.2/actionpack/CHANGELOG.md
|
|
353
|
-
documentation_uri: https://api.rubyonrails.org/v8.0.2/
|
|
352
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.0.5.2/actionpack/CHANGELOG.md
|
|
353
|
+
documentation_uri: https://api.rubyonrails.org/v8.0.5.2/
|
|
354
354
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
|
355
|
-
source_code_uri: https://github.com/rails/rails/tree/v8.0.2/actionpack
|
|
355
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.0.5.2/actionpack
|
|
356
356
|
rubygems_mfa_required: 'true'
|
|
357
357
|
rdoc_options: []
|
|
358
358
|
require_paths:
|
|
@@ -369,7 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
369
369
|
version: '0'
|
|
370
370
|
requirements:
|
|
371
371
|
- none
|
|
372
|
-
rubygems_version:
|
|
372
|
+
rubygems_version: 4.0.20
|
|
373
373
|
specification_version: 4
|
|
374
374
|
summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
|
|
375
375
|
test_files: []
|