actionpack 4.2.11.3 → 5.0.0.beta1

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.

Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +379 -462
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +2 -3
  5. data/lib/abstract_controller.rb +0 -2
  6. data/lib/abstract_controller/base.rb +17 -32
  7. data/lib/abstract_controller/callbacks.rb +52 -19
  8. data/lib/abstract_controller/collector.rb +4 -9
  9. data/lib/abstract_controller/helpers.rb +2 -2
  10. data/lib/abstract_controller/railties/routes_helpers.rb +2 -2
  11. data/lib/abstract_controller/rendering.rb +27 -22
  12. data/lib/abstract_controller/translation.rb +8 -7
  13. data/lib/action_controller.rb +4 -3
  14. data/lib/action_controller/api.rb +146 -0
  15. data/lib/action_controller/base.rb +6 -10
  16. data/lib/action_controller/caching.rb +1 -3
  17. data/lib/action_controller/caching/fragments.rb +48 -3
  18. data/lib/action_controller/form_builder.rb +48 -0
  19. data/lib/action_controller/log_subscriber.rb +1 -10
  20. data/lib/action_controller/metal.rb +89 -62
  21. data/lib/action_controller/metal/basic_implicit_render.rb +11 -0
  22. data/lib/action_controller/metal/conditional_get.rb +65 -24
  23. data/lib/action_controller/metal/cookies.rb +0 -2
  24. data/lib/action_controller/metal/data_streaming.rb +2 -22
  25. data/lib/action_controller/metal/etag_with_template_digest.rb +1 -1
  26. data/lib/action_controller/metal/exceptions.rb +11 -6
  27. data/lib/action_controller/metal/force_ssl.rb +6 -6
  28. data/lib/action_controller/metal/head.rb +14 -7
  29. data/lib/action_controller/metal/helpers.rb +9 -5
  30. data/lib/action_controller/metal/http_authentication.rb +37 -38
  31. data/lib/action_controller/metal/implicit_render.rb +23 -6
  32. data/lib/action_controller/metal/instrumentation.rb +0 -1
  33. data/lib/action_controller/metal/live.rb +17 -55
  34. data/lib/action_controller/metal/mime_responds.rb +17 -37
  35. data/lib/action_controller/metal/params_wrapper.rb +8 -8
  36. data/lib/action_controller/metal/redirecting.rb +32 -9
  37. data/lib/action_controller/metal/renderers.rb +10 -8
  38. data/lib/action_controller/metal/rendering.rb +38 -6
  39. data/lib/action_controller/metal/request_forgery_protection.rb +67 -35
  40. data/lib/action_controller/metal/rescue.rb +2 -4
  41. data/lib/action_controller/metal/streaming.rb +4 -4
  42. data/lib/action_controller/metal/strong_parameters.rb +231 -78
  43. data/lib/action_controller/metal/testing.rb +1 -12
  44. data/lib/action_controller/metal/url_for.rb +12 -5
  45. data/lib/action_controller/renderer.rb +111 -0
  46. data/lib/action_controller/template_assertions.rb +9 -0
  47. data/lib/action_controller/test_case.rb +267 -363
  48. data/lib/action_dispatch.rb +2 -1
  49. data/lib/action_dispatch/http/cache.rb +23 -26
  50. data/lib/action_dispatch/http/filter_parameters.rb +6 -8
  51. data/lib/action_dispatch/http/filter_redirect.rb +7 -8
  52. data/lib/action_dispatch/http/headers.rb +28 -11
  53. data/lib/action_dispatch/http/mime_negotiation.rb +40 -26
  54. data/lib/action_dispatch/http/mime_type.rb +92 -61
  55. data/lib/action_dispatch/http/mime_types.rb +1 -4
  56. data/lib/action_dispatch/http/parameter_filter.rb +18 -8
  57. data/lib/action_dispatch/http/parameters.rb +45 -41
  58. data/lib/action_dispatch/http/request.rb +146 -82
  59. data/lib/action_dispatch/http/response.rb +180 -99
  60. data/lib/action_dispatch/http/url.rb +117 -8
  61. data/lib/action_dispatch/journey/formatter.rb +34 -28
  62. data/lib/action_dispatch/journey/gtg/transition_table.rb +1 -1
  63. data/lib/action_dispatch/journey/nfa/dot.rb +0 -2
  64. data/lib/action_dispatch/journey/nfa/transition_table.rb +1 -46
  65. data/lib/action_dispatch/journey/nodes/node.rb +14 -4
  66. data/lib/action_dispatch/journey/parser_extras.rb +4 -0
  67. data/lib/action_dispatch/journey/path/pattern.rb +37 -41
  68. data/lib/action_dispatch/journey/route.rb +71 -17
  69. data/lib/action_dispatch/journey/router.rb +5 -6
  70. data/lib/action_dispatch/journey/router/utils.rb +5 -5
  71. data/lib/action_dispatch/journey/routes.rb +14 -15
  72. data/lib/action_dispatch/journey/visitors.rb +86 -43
  73. data/lib/action_dispatch/middleware/cookies.rb +184 -135
  74. data/lib/action_dispatch/middleware/debug_exceptions.rb +115 -45
  75. data/lib/action_dispatch/middleware/exception_wrapper.rb +21 -20
  76. data/lib/action_dispatch/middleware/flash.rb +61 -45
  77. data/lib/action_dispatch/middleware/load_interlock.rb +21 -0
  78. data/lib/action_dispatch/middleware/params_parser.rb +30 -46
  79. data/lib/action_dispatch/middleware/public_exceptions.rb +2 -2
  80. data/lib/action_dispatch/middleware/reloader.rb +2 -4
  81. data/lib/action_dispatch/middleware/remote_ip.rb +29 -19
  82. data/lib/action_dispatch/middleware/request_id.rb +11 -6
  83. data/lib/action_dispatch/middleware/session/abstract_store.rb +23 -11
  84. data/lib/action_dispatch/middleware/session/cache_store.rb +9 -6
  85. data/lib/action_dispatch/middleware/session/cookie_store.rb +29 -23
  86. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +4 -0
  87. data/lib/action_dispatch/middleware/show_exceptions.rb +11 -9
  88. data/lib/action_dispatch/middleware/ssl.rb +93 -36
  89. data/lib/action_dispatch/middleware/stack.rb +43 -48
  90. data/lib/action_dispatch/middleware/static.rb +52 -40
  91. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +2 -14
  92. data/lib/action_dispatch/middleware/templates/rescues/{_source.erb → _source.html.erb} +0 -0
  93. data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
  94. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -1
  95. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +1 -1
  96. data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +4 -4
  97. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +59 -63
  98. data/lib/action_dispatch/railtie.rb +0 -2
  99. data/lib/action_dispatch/request/session.rb +66 -34
  100. data/lib/action_dispatch/request/utils.rb +51 -19
  101. data/lib/action_dispatch/routing.rb +3 -8
  102. data/lib/action_dispatch/routing/inspector.rb +6 -30
  103. data/lib/action_dispatch/routing/mapper.rb +447 -322
  104. data/lib/action_dispatch/routing/polymorphic_routes.rb +8 -14
  105. data/lib/action_dispatch/routing/redirection.rb +3 -3
  106. data/lib/action_dispatch/routing/route_set.rb +124 -227
  107. data/lib/action_dispatch/routing/url_for.rb +27 -10
  108. data/lib/action_dispatch/testing/assertions.rb +1 -1
  109. data/lib/action_dispatch/testing/assertions/response.rb +27 -9
  110. data/lib/action_dispatch/testing/assertions/routing.rb +9 -9
  111. data/lib/action_dispatch/testing/integration.rb +237 -76
  112. data/lib/action_dispatch/testing/test_process.rb +5 -5
  113. data/lib/action_dispatch/testing/test_request.rb +12 -21
  114. data/lib/action_dispatch/testing/test_response.rb +1 -4
  115. data/lib/action_pack.rb +1 -1
  116. data/lib/action_pack/gem_version.rb +4 -4
  117. metadata +26 -25
  118. data/lib/action_controller/metal/hide_actions.rb +0 -40
  119. data/lib/action_controller/metal/rack_delegation.rb +0 -32
  120. data/lib/action_controller/middleware.rb +0 -39
  121. data/lib/action_controller/model_naming.rb +0 -12
  122. data/lib/action_dispatch/journey/router/strexp.rb +0 -27
  123. data/lib/action_dispatch/testing/assertions/dom.rb +0 -3
  124. data/lib/action_dispatch/testing/assertions/selector.rb +0 -3
  125. data/lib/action_dispatch/testing/assertions/tag.rb +0 -3
@@ -1,29 +1,37 @@
1
- require 'set'
2
1
  require 'singleton'
3
2
  require 'active_support/core_ext/module/attribute_accessors'
4
3
  require 'active_support/core_ext/string/starts_ends_with'
5
4
 
6
5
  module Mime
7
- class Mimes < Array
8
- def symbols
9
- @symbols ||= map { |m| m.to_sym }
6
+ class Mimes
7
+ include Enumerable
8
+
9
+ def initialize
10
+ @mimes = []
11
+ @symbols = nil
10
12
  end
11
13
 
12
- %w(<< concat shift unshift push pop []= clear compact! collect!
13
- delete delete_at delete_if flatten! map! insert reject! reverse!
14
- replace slice! sort! uniq!).each do |method|
15
- module_eval <<-CODE, __FILE__, __LINE__ + 1
16
- def #{method}(*)
17
- @symbols = nil
18
- super
19
- end
20
- CODE
14
+ def each
15
+ @mimes.each { |x| yield x }
16
+ end
17
+
18
+ def <<(type)
19
+ @mimes << type
20
+ @symbols = nil
21
+ end
22
+
23
+ def delete_if
24
+ @mimes.delete_if { |x| yield x }.tap { @symbols = nil }
25
+ end
26
+
27
+ def symbols
28
+ @symbols ||= map(&:to_sym)
21
29
  end
22
30
  end
23
31
 
24
32
  SET = Mimes.new
25
33
  EXTENSION_LOOKUP = {}
26
- LOOKUP = {}
34
+ LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }
27
35
 
28
36
  class << self
29
37
  def [](type)
@@ -35,6 +43,32 @@ module Mime
35
43
  return type if type.is_a?(Type)
36
44
  EXTENSION_LOOKUP.fetch(type.to_s) { |k| yield k }
37
45
  end
46
+
47
+ def const_missing(sym)
48
+ ext = sym.downcase
49
+ if Mime[ext]
50
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
51
+ Accessing mime types via constants is deprecated.
52
+ Please change `Mime::#{sym}` to `Mime[:#{ext}]`.
53
+ MSG
54
+ Mime[ext]
55
+ else
56
+ super
57
+ end
58
+ end
59
+
60
+ def const_defined?(sym, inherit = true)
61
+ ext = sym.downcase
62
+ if Mime[ext]
63
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
64
+ Accessing mime types via constants is deprecated.
65
+ Please change `Mime.const_defined?(#{sym})` to `Mime[:#{ext}]`.
66
+ MSG
67
+ true
68
+ else
69
+ super
70
+ end
71
+ end
38
72
  end
39
73
 
40
74
  # Encapsulates the notion of a mime type. Can be used at render time, for example, with:
@@ -45,15 +79,12 @@ module Mime
45
79
  #
46
80
  # respond_to do |format|
47
81
  # format.html
48
- # format.ics { render text: @post.to_ics, mime_type: Mime::Type["text/calendar"] }
82
+ # format.ics { render body: @post.to_ics, mime_type: Mime::Type.lookup("text/calendar") }
49
83
  # format.xml { render xml: @post }
50
84
  # end
51
85
  # end
52
86
  # end
53
87
  class Type
54
- @@html_types = Set.new [:html, :all]
55
- cattr_reader :html_types
56
-
57
88
  attr_reader :symbol
58
89
 
59
90
  @register_callbacks = []
@@ -66,7 +97,7 @@ module Mime
66
97
  def initialize(index, name, q = nil)
67
98
  @index = index
68
99
  @name = name
69
- q ||= 0.0 if @name == Mime::ALL.to_s # default wildcard match to end of list
100
+ q ||= 0.0 if @name == '*/*'.freeze # default wildcard match to end of list
70
101
  @q = ((q || 1.0).to_f * 100).to_i
71
102
  end
72
103
 
@@ -91,7 +122,7 @@ module Mime
91
122
  exchange_xml_items if app_xml_idx > text_xml_idx # make sure app_xml is ahead of text_xml in the list
92
123
  delete_at(text_xml_idx) # delete text_xml from the list
93
124
  elsif text_xml_idx
94
- text_xml.name = Mime::XML.to_s
125
+ text_xml.name = Mime[:xml].to_s
95
126
  end
96
127
 
97
128
  # Look for more specific XML-based types and sort them ahead of app/xml
@@ -120,7 +151,7 @@ module Mime
120
151
  end
121
152
 
122
153
  def app_xml_idx
123
- @app_xml_idx ||= index(Mime::XML.to_s)
154
+ @app_xml_idx ||= index(Mime[:xml].to_s)
124
155
  end
125
156
 
126
157
  def text_xml
@@ -146,7 +177,7 @@ module Mime
146
177
  end
147
178
 
148
179
  def lookup(string)
149
- LOOKUP[string] || Type.new(string)
180
+ LOOKUP[string]
150
181
  end
151
182
 
152
183
  def lookup_by_extension(extension)
@@ -160,17 +191,17 @@ module Mime
160
191
  end
161
192
 
162
193
  def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], skip_lookup = false)
163
- Mime.const_set(symbol.upcase, Type.new(string, symbol, mime_type_synonyms))
194
+ new_mime = Type.new(string, symbol, mime_type_synonyms)
164
195
 
165
- new_mime = Mime.const_get(symbol.upcase)
166
196
  SET << new_mime
167
197
 
168
- ([string] + mime_type_synonyms).each { |str| LOOKUP[str] = SET.last } unless skip_lookup
169
- ([symbol] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext.to_s] = SET.last }
198
+ ([string] + mime_type_synonyms).each { |str| LOOKUP[str] = new_mime } unless skip_lookup
199
+ ([symbol] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext.to_s] = new_mime }
170
200
 
171
201
  @register_callbacks.each do |callback|
172
202
  callback.call(new_mime)
173
203
  end
204
+ new_mime
174
205
  end
175
206
 
176
207
  def parse(accept_header)
@@ -200,37 +231,33 @@ module Mime
200
231
  parse_data_with_trailing_star($1) if accept_header =~ TRAILING_STAR_REGEXP
201
232
  end
202
233
 
203
- # For an input of <tt>'text'</tt>, returns <tt>[Mime::JSON, Mime::XML, Mime::ICS,
204
- # Mime::HTML, Mime::CSS, Mime::CSV, Mime::JS, Mime::YAML, Mime::TEXT]</tt>.
234
+ # For an input of <tt>'text'</tt>, returns <tt>[Mime[:json], Mime[:xml], Mime[:ics],
235
+ # Mime[:html], Mime[:css], Mime[:csv], Mime[:js], Mime[:yaml], Mime[:text]</tt>.
205
236
  #
206
- # For an input of <tt>'application'</tt>, returns <tt>[Mime::HTML, Mime::JS,
207
- # Mime::XML, Mime::YAML, Mime::ATOM, Mime::JSON, Mime::RSS, Mime::URL_ENCODED_FORM]</tt>.
208
- def parse_data_with_trailing_star(input)
209
- Mime::SET.select { |m| m =~ input }
237
+ # For an input of <tt>'application'</tt>, returns <tt>[Mime[:html], Mime[:js],
238
+ # Mime[:xml], Mime[:yaml], Mime[:atom], Mime[:json], Mime[:rss], Mime[:url_encoded_form]</tt>.
239
+ def parse_data_with_trailing_star(type)
240
+ Mime::SET.select { |m| m =~ type }
210
241
  end
211
242
 
212
243
  # This method is opposite of register method.
213
244
  #
214
- # Usage:
245
+ # To unregister a MIME type:
215
246
  #
216
247
  # Mime::Type.unregister(:mobile)
217
248
  def unregister(symbol)
218
- symbol = symbol.upcase
219
- mime = Mime.const_get(symbol)
220
- Mime.instance_eval { remove_const(symbol) }
221
-
222
- SET.delete_if { |v| v.eql?(mime) }
223
- LOOKUP.delete_if { |_,v| v.eql?(mime) }
224
- EXTENSION_LOOKUP.delete_if { |_,v| v.eql?(mime) }
249
+ symbol = symbol.downcase
250
+ if mime = Mime[symbol]
251
+ SET.delete_if { |v| v.eql?(mime) }
252
+ LOOKUP.delete_if { |_, v| v.eql?(mime) }
253
+ EXTENSION_LOOKUP.delete_if { |_, v| v.eql?(mime) }
254
+ end
225
255
  end
226
256
  end
227
257
 
228
- attr_reader :hash
229
-
230
258
  def initialize(string, symbol = nil, synonyms = [])
231
259
  @symbol, @synonyms = symbol, synonyms
232
260
  @string = string
233
- @hash = [@string, @synonyms, @symbol].hash
234
261
  end
235
262
 
236
263
  def to_s
@@ -246,7 +273,7 @@ module Mime
246
273
  end
247
274
 
248
275
  def ref
249
- to_sym || to_s
276
+ symbol || to_s
250
277
  end
251
278
 
252
279
  def ===(list)
@@ -258,35 +285,23 @@ module Mime
258
285
  end
259
286
 
260
287
  def ==(mime_type)
261
- return false if mime_type.blank?
288
+ return false unless mime_type
262
289
  (@synonyms + [ self ]).any? do |synonym|
263
290
  synonym.to_s == mime_type.to_s || synonym.to_sym == mime_type.to_sym
264
291
  end
265
292
  end
266
293
 
267
- def eql?(other)
268
- super || (self.class == other.class &&
269
- @string == other.string &&
270
- @synonyms == other.synonyms &&
271
- @symbol == other.symbol)
272
- end
273
-
274
294
  def =~(mime_type)
275
- return false if mime_type.blank?
295
+ return false unless mime_type
276
296
  regexp = Regexp.new(Regexp.quote(mime_type.to_s))
277
- (@synonyms + [ self ]).any? do |synonym|
278
- synonym.to_s =~ regexp
279
- end
297
+ @synonyms.any? { |synonym| synonym.to_s =~ regexp } || @string =~ regexp
280
298
  end
281
299
 
282
300
  def html?
283
- @@html_types.include?(to_sym) || @string =~ /html/
301
+ symbol == :html || @string =~ /html/
284
302
  end
285
303
 
286
-
287
- protected
288
-
289
- attr_reader :string, :synonyms
304
+ def all?; false; end
290
305
 
291
306
  private
292
307
 
@@ -306,6 +321,22 @@ module Mime
306
321
  end
307
322
  end
308
323
 
324
+ class AllType < Type
325
+ include Singleton
326
+
327
+ def initialize
328
+ super '*/*', :all
329
+ end
330
+
331
+ def all?; true; end
332
+ def html?; true; end
333
+ end
334
+
335
+ # ALL isn't a real MIME type, so we don't register it for lookup with the
336
+ # other concrete types. It's a wildcard match that we use for `respond_to`
337
+ # negotiation internals.
338
+ ALL = AllType.instance
339
+
309
340
  class NullType
310
341
  include Singleton
311
342
 
@@ -27,10 +27,7 @@ Mime::Type.register "application/x-www-form-urlencoded", :url_encoded_form
27
27
 
28
28
  # http://www.ietf.org/rfc/rfc4627.txt
29
29
  # http://www.json.org/JSONRequest.html
30
- Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest )
30
+ Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest application/vnd.api+json )
31
31
 
32
32
  Mime::Type.register "application/pdf", :pdf, [], %w(pdf)
33
33
  Mime::Type.register "application/zip", :zip, [], %w(zip)
34
-
35
- # Create Mime::ALL but do not add it to the SET.
36
- Mime::ALL = Mime::Type.new("*/*", :all, [])
@@ -30,36 +30,46 @@ module ActionDispatch
30
30
  when Regexp
31
31
  regexps << item
32
32
  else
33
- strings << item.to_s
33
+ strings << Regexp.escape(item.to_s)
34
34
  end
35
35
  end
36
36
 
37
- regexps << Regexp.new(strings.join('|'), true) unless strings.empty?
38
- new regexps, blocks
37
+ deep_regexps, regexps = regexps.partition { |r| r.to_s.include?("\\.".freeze) }
38
+ deep_strings, strings = strings.partition { |s| s.include?("\\.".freeze) }
39
+
40
+ regexps << Regexp.new(strings.join('|'.freeze), true) unless strings.empty?
41
+ deep_regexps << Regexp.new(deep_strings.join('|'.freeze), true) unless deep_strings.empty?
42
+
43
+ new regexps, deep_regexps, blocks
39
44
  end
40
45
 
41
- attr_reader :regexps, :blocks
46
+ attr_reader :regexps, :deep_regexps, :blocks
42
47
 
43
- def initialize(regexps, blocks)
48
+ def initialize(regexps, deep_regexps, blocks)
44
49
  @regexps = regexps
50
+ @deep_regexps = deep_regexps.any? ? deep_regexps : nil
45
51
  @blocks = blocks
46
52
  end
47
53
 
48
- def call(original_params)
54
+ def call(original_params, parents = [])
49
55
  filtered_params = {}
50
56
 
51
57
  original_params.each do |key, value|
58
+ parents.push(key) if deep_regexps
52
59
  if regexps.any? { |r| key =~ r }
53
60
  value = FILTERED
61
+ elsif deep_regexps && (joined = parents.join('.')) && deep_regexps.any? { |r| joined =~ r }
62
+ value = FILTERED
54
63
  elsif value.is_a?(Hash)
55
- value = call(value)
64
+ value = call(value, parents)
56
65
  elsif value.is_a?(Array)
57
- value = value.map { |v| v.is_a?(Hash) ? call(v) : v }
66
+ value = value.map { |v| v.is_a?(Hash) ? call(v, parents) : v }
58
67
  elsif blocks.any?
59
68
  key = key.dup if key.duplicable?
60
69
  value = value.dup if value.duplicable?
61
70
  blocks.each { |b| b.call(key, value) }
62
71
  end
72
+ parents.pop if deep_regexps
63
73
 
64
74
  filtered_params[key] = value
65
75
  end
@@ -1,35 +1,41 @@
1
- require 'active_support/core_ext/hash/keys'
2
- require 'active_support/core_ext/hash/indifferent_access'
3
- require 'active_support/deprecation'
4
-
5
1
  module ActionDispatch
6
2
  module Http
7
3
  module Parameters
8
4
  PARAMETERS_KEY = 'action_dispatch.request.path_parameters'
9
5
 
6
+ DEFAULT_PARSERS = {
7
+ Mime[:json] => lambda { |raw_post|
8
+ data = ActiveSupport::JSON.decode(raw_post)
9
+ data.is_a?(Hash) ? data : {:_json => data}
10
+ }
11
+ }
12
+
13
+ def self.included(klass)
14
+ class << klass
15
+ attr_accessor :parameter_parsers
16
+ end
17
+
18
+ klass.parameter_parsers = DEFAULT_PARSERS
19
+ end
10
20
  # Returns both GET and POST \parameters in a single hash.
11
21
  def parameters
12
- @env["action_dispatch.request.parameters"] ||= begin
13
- params = begin
14
- request_parameters.merge(query_parameters)
15
- rescue EOFError
16
- query_parameters.dup
17
- end
18
- params.merge!(path_parameters)
19
- end
22
+ params = get_header("action_dispatch.request.parameters")
23
+ return params if params
24
+
25
+ params = begin
26
+ request_parameters.merge(query_parameters)
27
+ rescue EOFError
28
+ query_parameters.dup
29
+ end
30
+ params.merge!(path_parameters)
31
+ set_header("action_dispatch.request.parameters", params)
32
+ params
20
33
  end
21
34
  alias :params :parameters
22
35
 
23
36
  def path_parameters=(parameters) #:nodoc:
24
- @env.delete('action_dispatch.request.parameters')
25
- @env[PARAMETERS_KEY] = parameters
26
- end
27
-
28
- def symbolized_path_parameters
29
- ActiveSupport::Deprecation.warn(
30
- '`symbolized_path_parameters` is deprecated. Please use `path_parameters`.'
31
- )
32
- path_parameters
37
+ delete_header('action_dispatch.request.parameters')
38
+ set_header PARAMETERS_KEY, parameters
33
39
  end
34
40
 
35
41
  # Returns a hash with the \parameters used to form the \path of the request.
@@ -37,31 +43,29 @@ module ActionDispatch
37
43
  #
38
44
  # {'action' => 'my_action', 'controller' => 'my_controller'}
39
45
  def path_parameters
40
- @env[PARAMETERS_KEY] ||= {}
46
+ get_header(PARAMETERS_KEY) || {}
41
47
  end
42
48
 
43
- private
49
+ private
44
50
 
45
- # Convert nested Hash to HashWithIndifferentAccess.
46
- #
47
- def normalize_encode_params(params)
48
- case params
49
- when Hash
50
- if params.has_key?(:tempfile)
51
- UploadedFile.new(params)
52
- else
53
- params.each_with_object({}) do |(key, val), new_hash|
54
- new_hash[key] = if val.is_a?(Array)
55
- val.map! { |el| normalize_encode_params(el) }
56
- else
57
- normalize_encode_params(val)
58
- end
59
- end.with_indifferent_access
60
- end
61
- else
62
- params
51
+ def parse_formatted_parameters(parsers)
52
+ return yield if content_length.zero?
53
+
54
+ strategy = parsers.fetch(content_mime_type) { return yield }
55
+
56
+ begin
57
+ strategy.call(raw_post)
58
+ rescue # JSON or Ruby code block errors
59
+ my_logger = logger || ActiveSupport::Logger.new($stderr)
60
+ my_logger.debug "Error occurred while parsing request parameters.\nContents:\n\n#{raw_post}"
61
+
62
+ raise ParamsParser::ParseError
63
63
  end
64
64
  end
65
+
66
+ def params_parsers
67
+ ActionDispatch::Request.parameter_parsers
68
+ end
65
69
  end
66
70
  end
67
71
  end