actionpack 3.1.12 → 3.2.0.rc1

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 (128) hide show
  1. data/CHANGELOG.md +5503 -108
  2. data/README.rdoc +3 -3
  3. data/lib/abstract_controller/asset_paths.rb +1 -1
  4. data/lib/abstract_controller/base.rb +1 -1
  5. data/lib/abstract_controller/callbacks.rb +102 -18
  6. data/lib/abstract_controller/helpers.rb +1 -1
  7. data/lib/abstract_controller/layouts.rb +116 -50
  8. data/lib/abstract_controller/logger.rb +1 -1
  9. data/lib/abstract_controller/railties/routes_helpers.rb +2 -2
  10. data/lib/abstract_controller/rendering.rb +1 -6
  11. data/lib/abstract_controller/view_paths.rb +6 -5
  12. data/lib/action_controller.rb +0 -15
  13. data/lib/action_controller/caching.rb +0 -1
  14. data/lib/action_controller/caching/actions.rb +5 -6
  15. data/lib/action_controller/caching/fragments.rb +18 -18
  16. data/lib/action_controller/caching/pages.rb +7 -6
  17. data/lib/action_controller/caching/sweeping.rb +1 -1
  18. data/lib/action_controller/log_subscriber.rb +8 -4
  19. data/lib/action_controller/metal.rb +7 -1
  20. data/lib/action_controller/metal/conditional_get.rb +49 -4
  21. data/lib/action_controller/metal/data_streaming.rb +17 -5
  22. data/lib/action_controller/metal/force_ssl.rb +8 -5
  23. data/lib/action_controller/metal/helpers.rb +7 -4
  24. data/lib/action_controller/metal/http_authentication.rb +9 -12
  25. data/lib/action_controller/metal/instrumentation.rb +9 -4
  26. data/lib/action_controller/metal/mime_responds.rb +4 -4
  27. data/lib/action_controller/metal/params_wrapper.rb +12 -8
  28. data/lib/action_controller/metal/redirecting.rb +7 -6
  29. data/lib/action_controller/metal/renderers.rb +9 -11
  30. data/lib/action_controller/metal/request_forgery_protection.rb +2 -1
  31. data/lib/action_controller/metal/rescue.rb +13 -0
  32. data/lib/action_controller/metal/responder.rb +11 -23
  33. data/lib/action_controller/metal/streaming.rb +0 -25
  34. data/lib/action_controller/railtie.rb +1 -0
  35. data/lib/action_controller/railties/paths.rb +4 -3
  36. data/lib/action_controller/record_identifier.rb +4 -4
  37. data/lib/action_controller/test_case.rb +60 -56
  38. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +6 -6
  39. data/lib/action_dispatch.rb +5 -1
  40. data/lib/action_dispatch/http/cache.rb +27 -15
  41. data/lib/action_dispatch/http/filter_parameters.rb +3 -1
  42. data/lib/action_dispatch/http/headers.rb +3 -5
  43. data/lib/action_dispatch/http/mime_negotiation.rb +2 -1
  44. data/lib/action_dispatch/http/mime_type.rb +7 -3
  45. data/lib/action_dispatch/http/mime_types.rb +12 -0
  46. data/lib/action_dispatch/http/parameter_filter.rb +3 -1
  47. data/lib/action_dispatch/http/parameters.rb +0 -4
  48. data/lib/action_dispatch/http/request.rb +18 -68
  49. data/lib/action_dispatch/http/response.rb +11 -32
  50. data/lib/action_dispatch/http/upload.rb +3 -14
  51. data/lib/action_dispatch/http/url.rb +1 -1
  52. data/lib/action_dispatch/middleware/callbacks.rb +1 -2
  53. data/lib/action_dispatch/middleware/cookies.rb +20 -16
  54. data/lib/action_dispatch/middleware/debug_exceptions.rb +82 -0
  55. data/lib/action_dispatch/middleware/exception_wrapper.rb +78 -0
  56. data/lib/action_dispatch/middleware/flash.rb +6 -9
  57. data/lib/action_dispatch/middleware/params_parser.rb +6 -11
  58. data/lib/action_dispatch/middleware/public_exceptions.rb +30 -0
  59. data/lib/action_dispatch/middleware/reloader.rb +38 -14
  60. data/lib/action_dispatch/middleware/remote_ip.rb +66 -36
  61. data/lib/action_dispatch/middleware/request_id.rb +39 -0
  62. data/lib/action_dispatch/middleware/session/abstract_store.rb +4 -16
  63. data/lib/action_dispatch/middleware/session/cache_store.rb +50 -0
  64. data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
  65. data/lib/action_dispatch/middleware/show_exceptions.rb +58 -142
  66. data/lib/action_dispatch/middleware/static.rb +2 -10
  67. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +1 -0
  68. data/lib/action_dispatch/middleware/templates/rescues/routing_error.erb +13 -8
  69. data/lib/action_dispatch/railtie.rb +15 -1
  70. data/lib/action_dispatch/routing.rb +1 -2
  71. data/lib/action_dispatch/routing/mapper.rb +108 -107
  72. data/lib/action_dispatch/routing/redirection.rb +63 -69
  73. data/lib/action_dispatch/routing/route_set.rb +75 -43
  74. data/lib/action_dispatch/routing/routes_proxy.rb +0 -4
  75. data/lib/action_dispatch/routing/url_for.rb +3 -3
  76. data/lib/action_dispatch/testing/assertions/response.rb +5 -7
  77. data/lib/action_dispatch/testing/assertions/routing.rb +10 -9
  78. data/lib/action_dispatch/testing/integration.rb +8 -25
  79. data/lib/action_dispatch/testing/test_process.rb +3 -2
  80. data/lib/action_dispatch/testing/test_request.rb +4 -23
  81. data/lib/action_pack/version.rb +3 -3
  82. data/lib/action_view.rb +1 -5
  83. data/lib/action_view/asset_paths.rb +7 -8
  84. data/lib/action_view/base.rb +7 -5
  85. data/lib/action_view/helpers/asset_paths.rb +1 -1
  86. data/lib/action_view/helpers/asset_tag_helper.rb +4 -8
  87. data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +3 -0
  88. data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
  89. data/lib/action_view/helpers/capture_helper.rb +3 -3
  90. data/lib/action_view/helpers/controller_helper.rb +1 -1
  91. data/lib/action_view/helpers/date_helper.rb +26 -18
  92. data/lib/action_view/helpers/debug_helper.rb +1 -1
  93. data/lib/action_view/helpers/form_helper.rb +71 -13
  94. data/lib/action_view/helpers/form_options_helper.rb +65 -34
  95. data/lib/action_view/helpers/form_tag_helper.rb +24 -18
  96. data/lib/action_view/helpers/javascript_helper.rb +12 -3
  97. data/lib/action_view/helpers/number_helper.rb +3 -2
  98. data/lib/action_view/helpers/record_tag_helper.rb +51 -5
  99. data/lib/action_view/helpers/rendering_helper.rb +2 -2
  100. data/lib/action_view/helpers/sanitize_helper.rb +6 -7
  101. data/lib/action_view/helpers/tag_helper.rb +1 -1
  102. data/lib/action_view/helpers/text_helper.rb +5 -4
  103. data/lib/action_view/helpers/url_helper.rb +19 -11
  104. data/lib/action_view/locale/en.yml +6 -0
  105. data/lib/action_view/log_subscriber.rb +1 -1
  106. data/lib/action_view/lookup_context.rb +123 -125
  107. data/lib/action_view/path_set.rb +60 -13
  108. data/lib/action_view/renderer/abstract_renderer.rb +16 -11
  109. data/lib/action_view/renderer/partial_renderer.rb +59 -40
  110. data/lib/action_view/renderer/template_renderer.rb +29 -17
  111. data/lib/action_view/template.rb +0 -1
  112. data/lib/action_view/template/error.rb +6 -5
  113. data/lib/action_view/template/handlers.rb +0 -6
  114. data/lib/action_view/template/handlers/builder.rb +10 -1
  115. data/lib/action_view/template/handlers/erb.rb +2 -2
  116. data/lib/action_view/template/resolver.rb +20 -31
  117. data/lib/action_view/test_case.rb +7 -10
  118. data/lib/sprockets/assets.rake +1 -1
  119. data/lib/sprockets/bootstrap.rb +3 -31
  120. data/lib/sprockets/compressors.rb +69 -7
  121. data/lib/sprockets/helpers/rails_helper.rb +6 -11
  122. data/lib/sprockets/railtie.rb +1 -0
  123. data/lib/sprockets/static_compiler.rb +0 -3
  124. metadata +57 -86
  125. checksums.yaml +0 -7
  126. data/lib/action_dispatch/middleware/closed_error.rb +0 -7
  127. data/lib/action_dispatch/routing/route.rb +0 -67
  128. data/lib/action_view/template/handler.rb +0 -49
@@ -26,6 +26,8 @@ module ActionDispatch
26
26
  module FilterParameters
27
27
  extend ActiveSupport::Concern
28
28
 
29
+ @@parameter_filter_for = {}
30
+
29
31
  # Return a hash of parameters with all sensitive data replaced.
30
32
  def filtered_parameters
31
33
  @filtered_parameters ||= parameter_filter.filter(parameters)
@@ -52,7 +54,7 @@ module ActionDispatch
52
54
  end
53
55
 
54
56
  def parameter_filter_for(filters)
55
- ParameterFilter.new(filters)
57
+ @@parameter_filter_for[filters] ||= ParameterFilter.new(filters)
56
58
  end
57
59
 
58
60
  KV_RE = '[^&;=]+'
@@ -1,11 +1,10 @@
1
- require 'active_support/memoizable'
2
-
3
1
  module ActionDispatch
4
2
  module Http
5
3
  class Headers < ::Hash
6
- extend ActiveSupport::Memoizable
4
+ @@env_cache = Hash.new { |h,k| h[k] = "HTTP_#{k.upcase.gsub(/-/, '_')}" }
7
5
 
8
6
  def initialize(*args)
7
+
9
8
  if args.size == 1 && args[0].is_a?(Hash)
10
9
  super()
11
10
  update(args[0])
@@ -25,9 +24,8 @@ module ActionDispatch
25
24
  private
26
25
  # Converts a HTTP header name to an environment variable name.
27
26
  def env_name(header_name)
28
- "HTTP_#{header_name.upcase.gsub(/-/, '_')}"
27
+ @@env_cache[header_name]
29
28
  end
30
- memoize :env_name
31
29
  end
32
30
  end
33
31
  end
@@ -98,7 +98,8 @@ module ActionDispatch
98
98
  BROWSER_LIKE_ACCEPTS = /,\s*\*\/\*|\*\/\*\s*,/
99
99
 
100
100
  def valid_accept_header
101
- xhr? || (accept && accept !~ BROWSER_LIKE_ACCEPTS)
101
+ (xhr? && (accept || content_mime_type)) ||
102
+ (accept && accept !~ BROWSER_LIKE_ACCEPTS)
102
103
  end
103
104
 
104
105
  def use_accept_header
@@ -47,7 +47,7 @@ module Mime
47
47
  cattr_reader :html_types
48
48
 
49
49
  # These are the content types which browsers can generate without using ajax, flash, etc
50
- # i.e. following a link, getting an image or posting a form. CSRF protection
50
+ # i.e. following a link, getting an image or posting a form. CSRF protection
51
51
  # only needs to protect against these types.
52
52
  @@browser_generated_types = Set.new [:html, :url_encoded_form, :multipart_form, :text]
53
53
  cattr_reader :browser_generated_types
@@ -103,7 +103,7 @@ module Mime
103
103
  SET << Mime.const_get(symbol.to_s.upcase)
104
104
 
105
105
  ([string] + mime_type_synonyms).each { |str| LOOKUP[str] = SET.last } unless skip_lookup
106
- ([symbol.to_s] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext] = SET.last }
106
+ ([symbol] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext.to_s] = SET.last }
107
107
  end
108
108
 
109
109
  def parse(accept_header)
@@ -246,7 +246,7 @@ module Mime
246
246
  end
247
247
  end
248
248
 
249
- # Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See
249
+ # Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See
250
250
  # ActionController::RequestForgeryProtection.
251
251
  def verify_request?
252
252
  @@browser_generated_types.include?(to_sym)
@@ -256,6 +256,10 @@ module Mime
256
256
  @@html_types.include?(to_sym) || @string =~ /html/
257
257
  end
258
258
 
259
+ def respond_to?(method, include_private = false) #:nodoc:
260
+ super || method.to_s =~ /(\w+)\?$/
261
+ end
262
+
259
263
  private
260
264
  def method_missing(method, *args)
261
265
  if method.to_s =~ /(\w+)\?$/
@@ -7,6 +7,15 @@ Mime::Type.register "text/javascript", :js, %w( application/javascript applicati
7
7
  Mime::Type.register "text/css", :css
8
8
  Mime::Type.register "text/calendar", :ics
9
9
  Mime::Type.register "text/csv", :csv
10
+
11
+ Mime::Type.register "image/png", :png, [], %w(png)
12
+ Mime::Type.register "image/jpeg", :jpeg, [], %w(jpg jpeg jpe)
13
+ Mime::Type.register "image/gif", :gif, [], %w(gif)
14
+ Mime::Type.register "image/bmp", :bmp, [], %w(bmp)
15
+ Mime::Type.register "image/tiff", :tiff, [], %w(tif tiff)
16
+
17
+ Mime::Type.register "video/mpeg", :mpeg, [], %w(mpg mpeg mpe)
18
+
10
19
  Mime::Type.register "application/xml", :xml, %w( text/xml application/x-xml )
11
20
  Mime::Type.register "application/rss+xml", :rss
12
21
  Mime::Type.register "application/atom+xml", :atom
@@ -19,5 +28,8 @@ Mime::Type.register "application/x-www-form-urlencoded", :url_encoded_form
19
28
  # http://www.json.org/JSONRequest.html
20
29
  Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest )
21
30
 
31
+ Mime::Type.register "application/pdf", :pdf, [], %w(pdf)
32
+ Mime::Type.register "application/zip", :zip, [], %w(zip)
33
+
22
34
  # Create Mime::ALL but do not add it to the SET.
23
35
  Mime::ALL = Mime::Type.new("*/*", :all, [])
@@ -20,6 +20,8 @@ module ActionDispatch
20
20
  @filters.present?
21
21
  end
22
22
 
23
+ FILTERED = '[FILTERED]'.freeze
24
+
23
25
  def compiled_filter
24
26
  @compiled_filter ||= begin
25
27
  regexps, blocks = compile_filter
@@ -29,7 +31,7 @@ module ActionDispatch
29
31
 
30
32
  original_params.each do |key, value|
31
33
  if regexps.find { |r| key =~ r }
32
- value = '[FILTERED]'
34
+ value = FILTERED
33
35
  elsif value.is_a?(Hash)
34
36
  value = filter(value)
35
37
  elsif value.is_a?(Array)
@@ -35,10 +35,6 @@ module ActionDispatch
35
35
  @env["action_dispatch.request.path_parameters"] ||= {}
36
36
  end
37
37
 
38
- def reset_parameters #:nodoc:
39
- @env.delete("action_dispatch.request.parameters")
40
- end
41
-
42
38
  private
43
39
 
44
40
  # TODO: Validate that the characters are UTF-8. If they aren't,
@@ -2,11 +2,11 @@ require 'tempfile'
2
2
  require 'stringio'
3
3
  require 'strscan'
4
4
 
5
- require 'active_support/core_ext/module/deprecation'
6
5
  require 'active_support/core_ext/hash/indifferent_access'
7
6
  require 'active_support/core_ext/string/access'
8
7
  require 'active_support/inflector'
9
8
  require 'action_dispatch/http/headers'
9
+ require 'action_controller/metal/exceptions'
10
10
 
11
11
  module ActionDispatch
12
12
  class Request < Rack::Request
@@ -26,7 +26,7 @@ module ActionDispatch
26
26
  HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
27
27
  HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
28
28
  HTTP_NEGOTIATE HTTP_PRAGMA ].freeze
29
-
29
+
30
30
  ENV_METHODS.each do |env|
31
31
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
32
32
  def #{env.sub(/^HTTP_/n, '').downcase} # def accept_charset
@@ -35,14 +35,6 @@ module ActionDispatch
35
35
  METHOD
36
36
  end
37
37
 
38
- def self.new(env)
39
- if request = env["action_dispatch.request"] && request.instance_of?(self)
40
- return request
41
- end
42
-
43
- super
44
- end
45
-
46
38
  def key?(key)
47
39
  @env.key?(key)
48
40
  end
@@ -94,31 +86,31 @@ module ActionDispatch
94
86
  end
95
87
 
96
88
  # Is this a GET (or HEAD) request?
97
- # Equivalent to <tt>request.request_method == :get</tt>.
89
+ # Equivalent to <tt>request.request_method_symbol == :get</tt>.
98
90
  def get?
99
91
  HTTP_METHOD_LOOKUP[request_method] == :get
100
92
  end
101
93
 
102
94
  # Is this a POST request?
103
- # Equivalent to <tt>request.request_method == :post</tt>.
95
+ # Equivalent to <tt>request.request_method_symbol == :post</tt>.
104
96
  def post?
105
97
  HTTP_METHOD_LOOKUP[request_method] == :post
106
98
  end
107
99
 
108
100
  # Is this a PUT request?
109
- # Equivalent to <tt>request.request_method == :put</tt>.
101
+ # Equivalent to <tt>request.request_method_symbol == :put</tt>.
110
102
  def put?
111
103
  HTTP_METHOD_LOOKUP[request_method] == :put
112
104
  end
113
105
 
114
106
  # Is this a DELETE request?
115
- # Equivalent to <tt>request.request_method == :delete</tt>.
107
+ # Equivalent to <tt>request.request_method_symbol == :delete</tt>.
116
108
  def delete?
117
109
  HTTP_METHOD_LOOKUP[request_method] == :delete
118
110
  end
119
111
 
120
112
  # Is this a HEAD request?
121
- # Equivalent to <tt>request.method == :head</tt>.
113
+ # Equivalent to <tt>request.method_symbol == :head</tt>.
122
114
  def head?
123
115
  HTTP_METHOD_LOOKUP[method] == :head
124
116
  end
@@ -130,23 +122,10 @@ module ActionDispatch
130
122
  Http::Headers.new(@env)
131
123
  end
132
124
 
133
- def original_fullpath
134
- @original_fullpath ||= (env["ORIGINAL_FULLPATH"] || fullpath)
135
- end
136
-
137
125
  def fullpath
138
126
  @fullpath ||= super
139
127
  end
140
128
 
141
- def original_url
142
- base_url + original_fullpath
143
- end
144
-
145
- def forgery_whitelisted?
146
- get?
147
- end
148
- deprecate :forgery_whitelisted? => "it is just an alias for 'get?' now, update your code"
149
-
150
129
  def media_type
151
130
  content_mime_type.to_s
152
131
  end
@@ -168,28 +147,21 @@ module ActionDispatch
168
147
  @ip ||= super
169
148
  end
170
149
 
171
- # Which IP addresses are "trusted proxies" that can be stripped from
172
- # the right-hand-side of X-Forwarded-For.
173
- #
174
- # http://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces.
175
- TRUSTED_PROXIES = %r{
176
- ^127\.0\.0\.1$ | # localhost
177
- ^(10 | # private IP 10.x.x.x
178
- 172\.(1[6-9]|2[0-9]|3[0-1]) | # private IP in the range 172.16.0.0 .. 172.31.255.255
179
- 192\.168 # private IP 192.168.x.x
180
- )\.
181
- }x
182
-
183
- # Determines originating IP address. REMOTE_ADDR is the standard
184
- # but will fail if the user is behind a proxy. HTTP_CLIENT_IP and/or
185
- # HTTP_X_FORWARDED_FOR are set by proxies so check for these if
186
- # REMOTE_ADDR is a proxy. HTTP_X_FORWARDED_FOR may be a comma-
187
- # delimited list in the case of multiple chained proxies; the last
188
- # address which is not trusted is the originating IP.
150
+ # Originating IP address, usually set by the RemoteIp middleware.
189
151
  def remote_ip
190
152
  @remote_ip ||= (@env["action_dispatch.remote_ip"] || ip).to_s
191
153
  end
192
154
 
155
+ # Returns the unique request id, which is based off either the X-Request-Id header that can
156
+ # be generated by a firewall, load balancer, or web server or by the RequestId middleware
157
+ # (which sets the action_dispatch.request_id environment variable).
158
+ #
159
+ # This unique ID is useful for tracing a request from end-to-end as part of logging or debugging.
160
+ # This relies on the rack variable set by the ActionDispatch::RequestId middleware.
161
+ def uuid
162
+ @uuid ||= env["action_dispatch.request_id"]
163
+ end
164
+
193
165
  # Returns the lowercase name of the HTTP server software.
194
166
  def server_software
195
167
  (@env['SERVER_SOFTWARE'] && /^([a-zA-Z]+)/ =~ @env['SERVER_SOFTWARE']) ? $1.downcase : nil
@@ -267,28 +239,6 @@ module ActionDispatch
267
239
  LOCALHOST.any? { |local_ip| local_ip === remote_addr && local_ip === remote_ip }
268
240
  end
269
241
 
270
- # Remove nils from the params hash
271
- def deep_munge(hash)
272
- hash.each do |k, v|
273
- case v
274
- when Array
275
- v.grep(Hash) { |x| deep_munge(x) }
276
- v.compact!
277
- hash[k] = nil if v.empty?
278
- when Hash
279
- deep_munge(v)
280
- end
281
- end
282
-
283
- hash
284
- end
285
-
286
- protected
287
-
288
- def parse_query(qs)
289
- deep_munge(super)
290
- end
291
-
292
242
  private
293
243
 
294
244
  def check_method(name)
@@ -53,8 +53,10 @@ module ActionDispatch # :nodoc:
53
53
  # information.
54
54
  attr_accessor :charset, :content_type
55
55
 
56
- CONTENT_TYPE = "Content-Type"
57
-
56
+ CONTENT_TYPE = "Content-Type".freeze
57
+ SET_COOKIE = "Set-Cookie".freeze
58
+ LOCATION = "Location".freeze
59
+
58
60
  cattr_accessor(:default_charset) { "utf-8" }
59
61
 
60
62
  include Rack::Response::Helpers
@@ -66,10 +68,10 @@ module ActionDispatch # :nodoc:
66
68
  @sending_file = false
67
69
  @blank = false
68
70
 
69
- if content_type = self["Content-Type"]
71
+ if content_type = self[CONTENT_TYPE]
70
72
  type, charset = content_type.split(/;\s*charset=/)
71
73
  @content_type = Mime::Type.lookup(type)
72
- @charset = charset || "UTF-8"
74
+ @charset = charset || self.class.default_charset
73
75
  end
74
76
 
75
77
  prepare_cache_control!
@@ -116,32 +118,9 @@ module ActionDispatch # :nodoc:
116
118
 
117
119
  EMPTY = " "
118
120
 
119
- class BodyBuster #:nodoc:
120
- def initialize(response)
121
- @response = response
122
- @body = ""
123
- end
124
-
125
- def bust(body)
126
- body.call(@response, self)
127
- body.close if body.respond_to?(:close)
128
- @body
129
- end
130
-
131
- def write(string)
132
- @body << string.to_s
133
- end
134
- end
135
-
136
121
  def body=(body)
137
122
  @blank = true if body == EMPTY
138
123
 
139
- if body.respond_to?(:call)
140
- ActiveSupport::Deprecation.warn "Setting a Proc or an object that responds to call " \
141
- "in response_body is no longer supported", caller
142
- body = BodyBuster.new(self).bust(body)
143
- end
144
-
145
124
  # Explicitly check for strings. This is *wrong* theoretically
146
125
  # but if we don't check this, the performance on string bodies
147
126
  # is bad on Ruby 1.8 (because strings responds to each then).
@@ -165,12 +144,12 @@ module ActionDispatch # :nodoc:
165
144
  end
166
145
 
167
146
  def location
168
- headers['Location']
147
+ headers[LOCATION]
169
148
  end
170
149
  alias_method :redirect_url, :location
171
150
 
172
151
  def location=(url)
173
- headers['Location'] = url
152
+ headers[LOCATION] = url
174
153
  end
175
154
 
176
155
  def close
@@ -181,10 +160,10 @@ module ActionDispatch # :nodoc:
181
160
  assign_default_content_type_and_charset!
182
161
  handle_conditional_get!
183
162
 
184
- @header["Set-Cookie"] = @header["Set-Cookie"].join("\n") if @header["Set-Cookie"].respond_to?(:join)
163
+ @header[SET_COOKIE] = @header[SET_COOKIE].join("\n") if @header[SET_COOKIE].respond_to?(:join)
185
164
 
186
165
  if [204, 304].include?(@status)
187
- @header.delete "Content-Type"
166
+ @header.delete CONTENT_TYPE
188
167
  [@status, @header, []]
189
168
  else
190
169
  [@status, @header, self]
@@ -198,7 +177,7 @@ module ActionDispatch # :nodoc:
198
177
  # assert_equal 'AuthorOfNewPage', r.cookies['author']
199
178
  def cookies
200
179
  cookies = {}
201
- if header = self["Set-Cookie"]
180
+ if header = self[SET_COOKIE]
202
181
  header = header.split("\n") if header.respond_to?(:to_str)
203
182
  header.each do |cookie|
204
183
  if pair = cookie.split(';').first
@@ -11,24 +11,13 @@ module ActionDispatch
11
11
  raise(ArgumentError, ':tempfile is required') unless @tempfile
12
12
  end
13
13
 
14
- def open
15
- @tempfile.open
16
- end
17
-
18
- def path
19
- @tempfile.path
20
- end
21
-
22
14
  def read(*args)
23
15
  @tempfile.read(*args)
24
16
  end
25
17
 
26
- def rewind
27
- @tempfile.rewind
28
- end
29
-
30
- def size
31
- @tempfile.size
18
+ # Delegate these methods to the tempfile.
19
+ [:open, :path, :rewind, :size].each do |method|
20
+ class_eval "def #{method}; @tempfile.#{method}; end"
32
21
  end
33
22
 
34
23
  private
@@ -45,7 +45,7 @@ module ActionDispatch
45
45
 
46
46
  rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
47
47
  rewritten_url << "?#{params.to_query}" unless params.empty?
48
- rewritten_url << "##{Rack::Mount::Utils.escape_uri(options[:anchor].to_param.to_s)}" if options[:anchor]
48
+ rewritten_url << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor]
49
49
  rewritten_url
50
50
  end
51
51
 
@@ -19,8 +19,7 @@ module ActionDispatch
19
19
  set_callback(:call, :after, *args, &block)
20
20
  end
21
21
 
22
- def initialize(app, unused = nil)
23
- ActiveSupport::Deprecation.warn "Passing a second argument to ActionDispatch::Callbacks.new is deprecated." unless unused.nil?
22
+ def initialize(app)
24
23
  @app = app
25
24
  end
26
25