actionpack 4.2.11.3 → 5.0.7.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +890 -384
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -3
- data/lib/abstract_controller/base.rb +28 -38
- data/lib/{action_controller → abstract_controller}/caching/fragments.rb +51 -11
- data/lib/abstract_controller/caching.rb +62 -0
- data/lib/abstract_controller/callbacks.rb +54 -19
- data/lib/abstract_controller/collector.rb +4 -9
- data/lib/abstract_controller/error.rb +4 -0
- data/lib/abstract_controller/helpers.rb +4 -3
- data/lib/abstract_controller/railties/routes_helpers.rb +2 -2
- data/lib/abstract_controller/rendering.rb +28 -18
- data/lib/abstract_controller/translation.rb +8 -7
- data/lib/abstract_controller.rb +6 -2
- data/lib/action_controller/api/api_rendering.rb +14 -0
- data/lib/action_controller/api.rb +147 -0
- data/lib/action_controller/base.rb +14 -11
- data/lib/action_controller/caching.rb +13 -58
- data/lib/action_controller/form_builder.rb +48 -0
- data/lib/action_controller/log_subscriber.rb +3 -10
- data/lib/action_controller/metal/basic_implicit_render.rb +11 -0
- data/lib/action_controller/metal/conditional_get.rb +106 -34
- data/lib/action_controller/metal/cookies.rb +1 -3
- data/lib/action_controller/metal/data_streaming.rb +14 -34
- data/lib/action_controller/metal/etag_with_template_digest.rb +8 -2
- data/lib/action_controller/metal/exceptions.rb +11 -6
- data/lib/action_controller/metal/force_ssl.rb +11 -11
- data/lib/action_controller/metal/head.rb +14 -8
- data/lib/action_controller/metal/helpers.rb +15 -6
- data/lib/action_controller/metal/http_authentication.rb +44 -35
- data/lib/action_controller/metal/implicit_render.rb +61 -6
- data/lib/action_controller/metal/instrumentation.rb +5 -5
- data/lib/action_controller/metal/live.rb +71 -88
- data/lib/action_controller/metal/mime_responds.rb +27 -42
- data/lib/action_controller/metal/params_wrapper.rb +9 -9
- data/lib/action_controller/metal/redirecting.rb +32 -9
- data/lib/action_controller/metal/renderers.rb +83 -40
- data/lib/action_controller/metal/rendering.rb +38 -6
- data/lib/action_controller/metal/request_forgery_protection.rb +126 -48
- data/lib/action_controller/metal/rescue.rb +3 -12
- data/lib/action_controller/metal/streaming.rb +4 -4
- data/lib/action_controller/metal/strong_parameters.rb +527 -134
- data/lib/action_controller/metal/testing.rb +1 -12
- data/lib/action_controller/metal/url_for.rb +12 -5
- data/lib/action_controller/metal.rb +88 -63
- data/lib/action_controller/railtie.rb +11 -7
- data/lib/action_controller/renderer.rb +113 -0
- data/lib/action_controller/template_assertions.rb +9 -0
- data/lib/action_controller/test_case.rb +311 -374
- data/lib/action_controller.rb +12 -9
- data/lib/action_dispatch/http/cache.rb +73 -34
- data/lib/action_dispatch/http/filter_parameters.rb +16 -12
- data/lib/action_dispatch/http/filter_redirect.rb +7 -8
- data/lib/action_dispatch/http/headers.rb +45 -14
- data/lib/action_dispatch/http/mime_negotiation.rb +42 -23
- data/lib/action_dispatch/http/mime_type.rb +126 -90
- data/lib/action_dispatch/http/mime_types.rb +3 -4
- data/lib/action_dispatch/http/parameter_filter.rb +19 -9
- data/lib/action_dispatch/http/parameters.rb +70 -40
- data/lib/action_dispatch/http/request.rb +144 -89
- data/lib/action_dispatch/http/response.rb +215 -102
- data/lib/action_dispatch/http/upload.rb +6 -2
- data/lib/action_dispatch/http/url.rb +117 -8
- data/lib/action_dispatch/journey/formatter.rb +47 -30
- data/lib/action_dispatch/journey/gtg/transition_table.rb +1 -1
- data/lib/action_dispatch/journey/nfa/dot.rb +0 -2
- data/lib/action_dispatch/journey/nfa/transition_table.rb +1 -46
- data/lib/action_dispatch/journey/nodes/node.rb +14 -4
- data/lib/action_dispatch/journey/parser.rb +2 -0
- data/lib/action_dispatch/journey/parser_extras.rb +8 -2
- data/lib/action_dispatch/journey/path/pattern.rb +38 -42
- data/lib/action_dispatch/journey/route.rb +88 -26
- data/lib/action_dispatch/journey/router/utils.rb +5 -5
- data/lib/action_dispatch/journey/router.rb +8 -10
- data/lib/action_dispatch/journey/routes.rb +14 -15
- data/lib/action_dispatch/journey/visitors.rb +89 -44
- data/lib/action_dispatch/middleware/callbacks.rb +10 -1
- data/lib/action_dispatch/middleware/cookies.rb +188 -134
- data/lib/action_dispatch/middleware/debug_exceptions.rb +128 -49
- data/lib/action_dispatch/middleware/debug_locks.rb +122 -0
- data/lib/action_dispatch/middleware/exception_wrapper.rb +21 -21
- data/lib/action_dispatch/middleware/executor.rb +19 -0
- data/lib/action_dispatch/middleware/flash.rb +66 -45
- data/lib/action_dispatch/middleware/params_parser.rb +32 -46
- data/lib/action_dispatch/middleware/public_exceptions.rb +2 -2
- data/lib/action_dispatch/middleware/reloader.rb +14 -58
- data/lib/action_dispatch/middleware/remote_ip.rb +29 -19
- data/lib/action_dispatch/middleware/request_id.rb +11 -6
- data/lib/action_dispatch/middleware/session/abstract_store.rb +23 -11
- data/lib/action_dispatch/middleware/session/cache_store.rb +9 -6
- data/lib/action_dispatch/middleware/session/cookie_store.rb +30 -24
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +4 -0
- data/lib/action_dispatch/middleware/show_exceptions.rb +11 -9
- data/lib/action_dispatch/middleware/ssl.rb +124 -36
- data/lib/action_dispatch/middleware/stack.rb +44 -40
- data/lib/action_dispatch/middleware/static.rb +51 -35
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +2 -14
- data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +4 -4
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +59 -63
- data/lib/action_dispatch/railtie.rb +2 -2
- data/lib/action_dispatch/request/session.rb +69 -33
- data/lib/action_dispatch/request/utils.rb +51 -19
- data/lib/action_dispatch/routing/inspector.rb +32 -43
- data/lib/action_dispatch/routing/mapper.rb +515 -348
- data/lib/action_dispatch/routing/polymorphic_routes.rb +8 -14
- data/lib/action_dispatch/routing/redirection.rb +5 -4
- data/lib/action_dispatch/routing/route_set.rb +148 -240
- data/lib/action_dispatch/routing/url_for.rb +27 -10
- data/lib/action_dispatch/routing.rb +17 -13
- data/lib/action_dispatch/testing/assertion_response.rb +45 -0
- data/lib/action_dispatch/testing/assertions/response.rb +38 -20
- data/lib/action_dispatch/testing/assertions/routing.rb +16 -12
- data/lib/action_dispatch/testing/assertions.rb +1 -1
- data/lib/action_dispatch/testing/integration.rb +377 -149
- data/lib/action_dispatch/testing/request_encoder.rb +53 -0
- data/lib/action_dispatch/testing/test_process.rb +24 -20
- data/lib/action_dispatch/testing/test_request.rb +22 -31
- data/lib/action_dispatch/testing/test_response.rb +12 -4
- data/lib/action_dispatch.rb +4 -1
- data/lib/action_pack/gem_version.rb +4 -4
- data/lib/action_pack.rb +1 -1
- metadata +32 -34
- data/lib/action_controller/metal/hide_actions.rb +0 -40
- data/lib/action_controller/metal/rack_delegation.rb +0 -32
- data/lib/action_controller/middleware.rb +0 -39
- data/lib/action_controller/model_naming.rb +0 -12
- data/lib/action_dispatch/journey/backwards.rb +0 -5
- data/lib/action_dispatch/journey/router/strexp.rb +0 -27
- data/lib/action_dispatch/testing/assertions/dom.rb +0 -3
- data/lib/action_dispatch/testing/assertions/selector.rb +0 -3
- data/lib/action_dispatch/testing/assertions/tag.rb +0 -3
- /data/lib/action_dispatch/middleware/templates/rescues/{_source.erb → _source.html.erb} +0 -0
@@ -13,12 +13,14 @@ require 'action_dispatch/http/url'
|
|
13
13
|
require 'active_support/core_ext/array/conversions'
|
14
14
|
|
15
15
|
module ActionDispatch
|
16
|
-
class Request
|
16
|
+
class Request
|
17
|
+
include Rack::Request::Helpers
|
17
18
|
include ActionDispatch::Http::Cache::Request
|
18
19
|
include ActionDispatch::Http::MimeNegotiation
|
19
20
|
include ActionDispatch::Http::Parameters
|
20
21
|
include ActionDispatch::Http::FilterParameters
|
21
22
|
include ActionDispatch::Http::URL
|
23
|
+
include Rack::Request::Env
|
22
24
|
|
23
25
|
autoload :Session, 'action_dispatch/request/session'
|
24
26
|
autoload :Utils, 'action_dispatch/request/utils'
|
@@ -29,19 +31,28 @@ module ActionDispatch
|
|
29
31
|
PATH_TRANSLATED REMOTE_HOST
|
30
32
|
REMOTE_IDENT REMOTE_USER REMOTE_ADDR
|
31
33
|
SERVER_NAME SERVER_PROTOCOL
|
34
|
+
ORIGINAL_SCRIPT_NAME
|
32
35
|
|
33
36
|
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
|
34
37
|
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
|
35
|
-
HTTP_NEGOTIATE HTTP_PRAGMA
|
38
|
+
HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP
|
39
|
+
HTTP_X_FORWARDED_FOR HTTP_ORIGIN HTTP_VERSION
|
40
|
+
HTTP_X_CSRF_TOKEN HTTP_X_REQUEST_ID HTTP_X_FORWARDED_HOST
|
41
|
+
SERVER_ADDR
|
42
|
+
].freeze
|
36
43
|
|
37
44
|
ENV_METHODS.each do |env|
|
38
45
|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
39
46
|
def #{env.sub(/^HTTP_/n, '').downcase} # def accept_charset
|
40
|
-
|
47
|
+
get_header "#{env}".freeze # get_header "HTTP_ACCEPT_CHARSET".freeze
|
41
48
|
end # end
|
42
49
|
METHOD
|
43
50
|
end
|
44
51
|
|
52
|
+
def self.empty
|
53
|
+
new({})
|
54
|
+
end
|
55
|
+
|
45
56
|
def initialize(env)
|
46
57
|
super
|
47
58
|
@method = nil
|
@@ -50,22 +61,31 @@ module ActionDispatch
|
|
50
61
|
@original_fullpath = nil
|
51
62
|
@fullpath = nil
|
52
63
|
@ip = nil
|
53
|
-
@uuid = nil
|
54
64
|
end
|
55
65
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
66
|
+
def commit_cookie_jar! # :nodoc:
|
67
|
+
end
|
68
|
+
|
69
|
+
PASS_NOT_FOUND = Class.new { # :nodoc:
|
70
|
+
def self.action(_); self; end
|
71
|
+
def self.call(_); [404, {'X-Cascade' => 'pass'}, []]; end
|
72
|
+
}
|
73
|
+
|
74
|
+
def controller_class
|
75
|
+
params = path_parameters
|
76
|
+
|
77
|
+
if params.key?(:controller)
|
78
|
+
controller_param = params[:controller].underscore
|
79
|
+
params[:action] ||= 'index'
|
80
|
+
const_name = "#{controller_param.camelize}Controller"
|
81
|
+
ActiveSupport::Dependencies.constantize(const_name)
|
82
|
+
else
|
83
|
+
PASS_NOT_FOUND
|
64
84
|
end
|
65
85
|
end
|
66
86
|
|
67
87
|
def key?(key)
|
68
|
-
|
88
|
+
has_header? key
|
69
89
|
end
|
70
90
|
|
71
91
|
# List of HTTP request methods from the following RFCs:
|
@@ -102,15 +122,50 @@ module ActionDispatch
|
|
102
122
|
# the application should use), this \method returns the overridden
|
103
123
|
# value, not the original.
|
104
124
|
def request_method
|
105
|
-
@request_method ||= check_method(
|
125
|
+
@request_method ||= check_method(super)
|
126
|
+
end
|
127
|
+
|
128
|
+
def routes # :nodoc:
|
129
|
+
get_header("action_dispatch.routes".freeze)
|
130
|
+
end
|
131
|
+
|
132
|
+
def routes=(routes) # :nodoc:
|
133
|
+
set_header("action_dispatch.routes".freeze, routes)
|
134
|
+
end
|
135
|
+
|
136
|
+
def engine_script_name(_routes) # :nodoc:
|
137
|
+
get_header(_routes.env_key)
|
138
|
+
end
|
139
|
+
|
140
|
+
def engine_script_name=(name) # :nodoc:
|
141
|
+
set_header(routes.env_key, name.dup)
|
106
142
|
end
|
107
143
|
|
108
144
|
def request_method=(request_method) #:nodoc:
|
109
145
|
if check_method(request_method)
|
110
|
-
@request_method =
|
146
|
+
@request_method = set_header("REQUEST_METHOD", request_method)
|
111
147
|
end
|
112
148
|
end
|
113
149
|
|
150
|
+
def controller_instance # :nodoc:
|
151
|
+
get_header('action_controller.instance'.freeze)
|
152
|
+
end
|
153
|
+
|
154
|
+
def controller_instance=(controller) # :nodoc:
|
155
|
+
set_header('action_controller.instance'.freeze, controller)
|
156
|
+
end
|
157
|
+
|
158
|
+
def http_auth_salt
|
159
|
+
get_header "action_dispatch.http_auth_salt"
|
160
|
+
end
|
161
|
+
|
162
|
+
def show_exceptions? # :nodoc:
|
163
|
+
# We're treating `nil` as "unset", and we want the default setting to be
|
164
|
+
# `true`. This logic should be extracted to `env_config` and calculated
|
165
|
+
# once.
|
166
|
+
!(get_header('action_dispatch.show_exceptions'.freeze) == false)
|
167
|
+
end
|
168
|
+
|
114
169
|
# Returns a symbol form of the #request_method
|
115
170
|
def request_method_symbol
|
116
171
|
HTTP_METHOD_LOOKUP[request_method]
|
@@ -120,7 +175,7 @@ module ActionDispatch
|
|
120
175
|
# even if it was overridden by middleware. See #request_method for
|
121
176
|
# more information.
|
122
177
|
def method
|
123
|
-
@method ||= check_method(
|
178
|
+
@method ||= check_method(get_header("rack.methodoverride.original_method") || get_header('REQUEST_METHOD'))
|
124
179
|
end
|
125
180
|
|
126
181
|
# Returns a symbol form of the #method
|
@@ -128,47 +183,11 @@ module ActionDispatch
|
|
128
183
|
HTTP_METHOD_LOOKUP[method]
|
129
184
|
end
|
130
185
|
|
131
|
-
# Is this a GET (or HEAD) request?
|
132
|
-
# Equivalent to <tt>request.request_method_symbol == :get</tt>.
|
133
|
-
def get?
|
134
|
-
HTTP_METHOD_LOOKUP[request_method] == :get
|
135
|
-
end
|
136
|
-
|
137
|
-
# Is this a POST request?
|
138
|
-
# Equivalent to <tt>request.request_method_symbol == :post</tt>.
|
139
|
-
def post?
|
140
|
-
HTTP_METHOD_LOOKUP[request_method] == :post
|
141
|
-
end
|
142
|
-
|
143
|
-
# Is this a PATCH request?
|
144
|
-
# Equivalent to <tt>request.request_method == :patch</tt>.
|
145
|
-
def patch?
|
146
|
-
HTTP_METHOD_LOOKUP[request_method] == :patch
|
147
|
-
end
|
148
|
-
|
149
|
-
# Is this a PUT request?
|
150
|
-
# Equivalent to <tt>request.request_method_symbol == :put</tt>.
|
151
|
-
def put?
|
152
|
-
HTTP_METHOD_LOOKUP[request_method] == :put
|
153
|
-
end
|
154
|
-
|
155
|
-
# Is this a DELETE request?
|
156
|
-
# Equivalent to <tt>request.request_method_symbol == :delete</tt>.
|
157
|
-
def delete?
|
158
|
-
HTTP_METHOD_LOOKUP[request_method] == :delete
|
159
|
-
end
|
160
|
-
|
161
|
-
# Is this a HEAD request?
|
162
|
-
# Equivalent to <tt>request.request_method_symbol == :head</tt>.
|
163
|
-
def head?
|
164
|
-
HTTP_METHOD_LOOKUP[request_method] == :head
|
165
|
-
end
|
166
|
-
|
167
186
|
# Provides access to the request's HTTP headers, for example:
|
168
187
|
#
|
169
188
|
# request.headers["Content-Type"] # => "text/plain"
|
170
189
|
def headers
|
171
|
-
Http::Headers.new(
|
190
|
+
@headers ||= Http::Headers.new(self)
|
172
191
|
end
|
173
192
|
|
174
193
|
# Returns a +String+ with the last requested path including their params.
|
@@ -179,7 +198,7 @@ module ActionDispatch
|
|
179
198
|
# # get '/foo?bar'
|
180
199
|
# request.original_fullpath # => '/foo?bar'
|
181
200
|
def original_fullpath
|
182
|
-
@original_fullpath ||= (
|
201
|
+
@original_fullpath ||= (get_header("ORIGINAL_FULLPATH") || fullpath)
|
183
202
|
end
|
184
203
|
|
185
204
|
# Returns the +String+ full path including params of the last URL requested.
|
@@ -218,62 +237,84 @@ module ActionDispatch
|
|
218
237
|
# (case-insensitive), which may need to be manually added depending on the
|
219
238
|
# choice of JavaScript libraries and frameworks.
|
220
239
|
def xml_http_request?
|
221
|
-
|
240
|
+
get_header('HTTP_X_REQUESTED_WITH') =~ /XMLHttpRequest/i
|
222
241
|
end
|
223
242
|
alias :xhr? :xml_http_request?
|
224
243
|
|
244
|
+
# Returns the IP address of client as a +String+.
|
225
245
|
def ip
|
226
246
|
@ip ||= super
|
227
247
|
end
|
228
248
|
|
229
|
-
#
|
249
|
+
# Returns the IP address of client as a +String+,
|
250
|
+
# usually set by the RemoteIp middleware.
|
230
251
|
def remote_ip
|
231
|
-
@remote_ip ||= (
|
252
|
+
@remote_ip ||= (get_header("action_dispatch.remote_ip") || ip).to_s
|
253
|
+
end
|
254
|
+
|
255
|
+
def remote_ip=(remote_ip)
|
256
|
+
set_header "action_dispatch.remote_ip".freeze, remote_ip
|
232
257
|
end
|
233
258
|
|
259
|
+
ACTION_DISPATCH_REQUEST_ID = "action_dispatch.request_id".freeze # :nodoc:
|
260
|
+
|
234
261
|
# Returns the unique request id, which is based on either the X-Request-Id header that can
|
235
262
|
# be generated by a firewall, load balancer, or web server or by the RequestId middleware
|
236
263
|
# (which sets the action_dispatch.request_id environment variable).
|
237
264
|
#
|
238
265
|
# This unique ID is useful for tracing a request from end-to-end as part of logging or debugging.
|
239
266
|
# This relies on the rack variable set by the ActionDispatch::RequestId middleware.
|
240
|
-
def
|
241
|
-
|
267
|
+
def request_id
|
268
|
+
get_header ACTION_DISPATCH_REQUEST_ID
|
269
|
+
end
|
270
|
+
|
271
|
+
def request_id=(id) # :nodoc:
|
272
|
+
set_header ACTION_DISPATCH_REQUEST_ID, id
|
242
273
|
end
|
243
274
|
|
275
|
+
alias_method :uuid, :request_id
|
276
|
+
|
244
277
|
# Returns the lowercase name of the HTTP server software.
|
245
278
|
def server_software
|
246
|
-
(
|
279
|
+
(get_header('SERVER_SOFTWARE') && /^([a-zA-Z]+)/ =~ get_header('SERVER_SOFTWARE')) ? $1.downcase : nil
|
247
280
|
end
|
248
281
|
|
249
282
|
# Read the request \body. This is useful for web services that need to
|
250
283
|
# work with raw requests directly.
|
251
284
|
def raw_post
|
252
|
-
unless
|
285
|
+
unless has_header? 'RAW_POST_DATA'
|
253
286
|
raw_post_body = body
|
254
|
-
|
287
|
+
set_header('RAW_POST_DATA', raw_post_body.read(content_length))
|
255
288
|
raw_post_body.rewind if raw_post_body.respond_to?(:rewind)
|
256
289
|
end
|
257
|
-
|
290
|
+
get_header 'RAW_POST_DATA'
|
258
291
|
end
|
259
292
|
|
260
293
|
# The request body is an IO input stream. If the RAW_POST_DATA environment
|
261
294
|
# variable is already set, wrap it in a StringIO.
|
262
295
|
def body
|
263
|
-
if raw_post =
|
296
|
+
if raw_post = get_header('RAW_POST_DATA')
|
264
297
|
raw_post.force_encoding(Encoding::BINARY)
|
265
298
|
StringIO.new(raw_post)
|
266
299
|
else
|
267
|
-
|
300
|
+
body_stream
|
268
301
|
end
|
269
302
|
end
|
270
303
|
|
304
|
+
# Determine whether the request body contains form-data by checking
|
305
|
+
# the request Content-Type for one of the media-types:
|
306
|
+
# "application/x-www-form-urlencoded" or "multipart/form-data". The
|
307
|
+
# list of form-data media types can be modified through the
|
308
|
+
# +FORM_DATA_MEDIA_TYPES+ array.
|
309
|
+
#
|
310
|
+
# A request body is not assumed to contain form-data when no
|
311
|
+
# Content-Type header is provided and the request_method is POST.
|
271
312
|
def form_data?
|
272
|
-
FORM_DATA_MEDIA_TYPES.include?(
|
313
|
+
FORM_DATA_MEDIA_TYPES.include?(media_type)
|
273
314
|
end
|
274
315
|
|
275
316
|
def body_stream #:nodoc:
|
276
|
-
|
317
|
+
get_header('rack.input')
|
277
318
|
end
|
278
319
|
|
279
320
|
# TODO This should be broken apart into AD::Request::Session and probably
|
@@ -284,60 +325,74 @@ module ActionDispatch
|
|
284
325
|
else
|
285
326
|
self.session = {}
|
286
327
|
end
|
287
|
-
@env['action_dispatch.request.flash_hash'] = nil
|
288
328
|
end
|
289
329
|
|
290
330
|
def session=(session) #:nodoc:
|
291
|
-
Session.set
|
331
|
+
Session.set self, session
|
292
332
|
end
|
293
333
|
|
294
334
|
def session_options=(options)
|
295
|
-
Session::Options.set
|
335
|
+
Session::Options.set self, options
|
296
336
|
end
|
297
337
|
|
298
338
|
# Override Rack's GET method to support indifferent access
|
299
339
|
def GET
|
300
|
-
|
340
|
+
fetch_header("action_dispatch.request.query_parameters") do |k|
|
341
|
+
rack_query_params = super || {}
|
342
|
+
# Check for non UTF-8 parameter values, which would cause errors later
|
343
|
+
Request::Utils.check_param_encoding(rack_query_params)
|
344
|
+
set_header k, Request::Utils.normalize_encode_params(rack_query_params)
|
345
|
+
end
|
301
346
|
rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e
|
302
|
-
raise ActionController::BadRequest.new(
|
347
|
+
raise ActionController::BadRequest.new("Invalid query parameters: #{e.message}")
|
303
348
|
end
|
304
349
|
alias :query_parameters :GET
|
305
350
|
|
306
351
|
# Override Rack's POST method to support indifferent access
|
307
352
|
def POST
|
308
|
-
|
353
|
+
fetch_header("action_dispatch.request.request_parameters") do
|
354
|
+
pr = parse_formatted_parameters(params_parsers) do |params|
|
355
|
+
super || {}
|
356
|
+
end
|
357
|
+
self.request_parameters = Request::Utils.normalize_encode_params(pr)
|
358
|
+
end
|
359
|
+
rescue ParamsParser::ParseError # one of the parse strategies blew up
|
360
|
+
self.request_parameters = Request::Utils.normalize_encode_params(super || {})
|
361
|
+
raise
|
309
362
|
rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e
|
310
|
-
raise ActionController::BadRequest.new(
|
363
|
+
raise ActionController::BadRequest.new("Invalid request parameters: #{e.message}")
|
311
364
|
end
|
312
365
|
alias :request_parameters :POST
|
313
366
|
|
314
367
|
# Returns the authorization header regardless of whether it was specified directly or through one of the
|
315
368
|
# proxy alternatives.
|
316
369
|
def authorization
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
370
|
+
get_header('HTTP_AUTHORIZATION') ||
|
371
|
+
get_header('X-HTTP_AUTHORIZATION') ||
|
372
|
+
get_header('X_HTTP_AUTHORIZATION') ||
|
373
|
+
get_header('REDIRECT_X_HTTP_AUTHORIZATION')
|
321
374
|
end
|
322
375
|
|
323
|
-
# True if the request came from localhost, 127.0.0.1.
|
376
|
+
# True if the request came from localhost, 127.0.0.1, or ::1.
|
324
377
|
def local?
|
325
378
|
LOCALHOST =~ remote_addr && LOCALHOST =~ remote_ip
|
326
379
|
end
|
327
380
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
)
|
381
|
+
def request_parameters=(params)
|
382
|
+
raise if params.nil?
|
383
|
+
set_header("action_dispatch.request.request_parameters".freeze, params)
|
384
|
+
end
|
333
385
|
|
334
|
-
|
386
|
+
def logger
|
387
|
+
get_header("action_dispatch.logger".freeze)
|
335
388
|
end
|
336
389
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
390
|
+
def commit_flash
|
391
|
+
end
|
392
|
+
|
393
|
+
def ssl?
|
394
|
+
super || scheme == 'wss'.freeze
|
395
|
+
end
|
341
396
|
|
342
397
|
private
|
343
398
|
def check_method(name)
|