rack 2.0.9.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +808 -0
  3. data/CONTRIBUTING.md +142 -0
  4. data/{COPYING → MIT-LICENSE} +4 -2
  5. data/README.md +293 -0
  6. data/SPEC.rdoc +340 -0
  7. data/lib/rack/auth/abstract/handler.rb +6 -2
  8. data/lib/rack/auth/abstract/request.rb +4 -2
  9. data/lib/rack/auth/basic.rb +7 -4
  10. data/lib/rack/auth/digest/md5.rb +1 -129
  11. data/lib/rack/auth/digest/nonce.rb +1 -51
  12. data/lib/rack/auth/digest/params.rb +1 -52
  13. data/lib/rack/auth/digest/request.rb +1 -41
  14. data/lib/rack/auth/digest.rb +256 -0
  15. data/lib/rack/body_proxy.rb +18 -15
  16. data/lib/rack/builder.rb +151 -40
  17. data/lib/rack/cascade.rb +30 -12
  18. data/lib/rack/chunked.rb +74 -23
  19. data/lib/rack/common_logger.rb +49 -36
  20. data/lib/rack/conditional_get.rb +33 -26
  21. data/lib/rack/config.rb +2 -0
  22. data/lib/rack/constants.rb +63 -0
  23. data/lib/rack/content_length.rb +13 -16
  24. data/lib/rack/content_type.rb +12 -8
  25. data/lib/rack/deflater.rb +84 -45
  26. data/lib/rack/directory.rb +90 -64
  27. data/lib/rack/etag.rb +17 -23
  28. data/lib/rack/events.rb +23 -20
  29. data/lib/rack/file.rb +5 -172
  30. data/lib/rack/files.rb +216 -0
  31. data/lib/rack/head.rb +10 -9
  32. data/lib/rack/headers.rb +154 -0
  33. data/lib/rack/lint.rb +786 -645
  34. data/lib/rack/lock.rb +4 -6
  35. data/lib/rack/logger.rb +4 -0
  36. data/lib/rack/media_type.rb +10 -5
  37. data/lib/rack/method_override.rb +8 -2
  38. data/lib/rack/mime.rb +17 -1
  39. data/lib/rack/mock.rb +2 -195
  40. data/lib/rack/mock_request.rb +166 -0
  41. data/lib/rack/mock_response.rb +126 -0
  42. data/lib/rack/multipart/generator.rb +21 -15
  43. data/lib/rack/multipart/parser.rb +161 -118
  44. data/lib/rack/multipart/uploaded_file.rb +19 -7
  45. data/lib/rack/multipart.rb +23 -41
  46. data/lib/rack/null_logger.rb +11 -0
  47. data/lib/rack/query_parser.rb +126 -65
  48. data/lib/rack/recursive.rb +9 -5
  49. data/lib/rack/reloader.rb +6 -4
  50. data/lib/rack/request.rb +331 -74
  51. data/lib/rack/response.rb +223 -70
  52. data/lib/rack/rewindable_input.rb +28 -8
  53. data/lib/rack/runtime.rb +11 -8
  54. data/lib/rack/sendfile.rb +42 -33
  55. data/lib/rack/show_exceptions.rb +35 -18
  56. data/lib/rack/show_status.rb +25 -15
  57. data/lib/rack/static.rb +30 -18
  58. data/lib/rack/tempfile_reaper.rb +16 -5
  59. data/lib/rack/urlmap.rb +14 -6
  60. data/lib/rack/utils.rb +268 -260
  61. data/lib/rack/version.rb +34 -0
  62. data/lib/rack.rb +15 -92
  63. metadata +44 -207
  64. data/HISTORY.md +0 -520
  65. data/README.rdoc +0 -316
  66. data/Rakefile +0 -116
  67. data/SPEC +0 -263
  68. data/bin/rackup +0 -4
  69. data/contrib/rack.png +0 -0
  70. data/contrib/rack.svg +0 -150
  71. data/contrib/rack_logo.svg +0 -164
  72. data/contrib/rdoc.css +0 -412
  73. data/example/lobster.ru +0 -4
  74. data/example/protectedlobster.rb +0 -14
  75. data/example/protectedlobster.ru +0 -8
  76. data/lib/rack/handler/cgi.rb +0 -60
  77. data/lib/rack/handler/fastcgi.rb +0 -100
  78. data/lib/rack/handler/lsws.rb +0 -61
  79. data/lib/rack/handler/scgi.rb +0 -70
  80. data/lib/rack/handler/thin.rb +0 -36
  81. data/lib/rack/handler/webrick.rb +0 -120
  82. data/lib/rack/handler.rb +0 -99
  83. data/lib/rack/lobster.rb +0 -70
  84. data/lib/rack/server.rb +0 -395
  85. data/lib/rack/session/abstract/id.rb +0 -510
  86. data/lib/rack/session/cookie.rb +0 -204
  87. data/lib/rack/session/memcache.rb +0 -99
  88. data/lib/rack/session/pool.rb +0 -83
  89. data/rack.gemspec +0 -34
  90. data/test/builder/an_underscore_app.rb +0 -5
  91. data/test/builder/anything.rb +0 -5
  92. data/test/builder/comment.ru +0 -4
  93. data/test/builder/end.ru +0 -5
  94. data/test/builder/line.ru +0 -1
  95. data/test/builder/options.ru +0 -2
  96. data/test/cgi/assets/folder/test.js +0 -1
  97. data/test/cgi/assets/fonts/font.eot +0 -1
  98. data/test/cgi/assets/images/image.png +0 -1
  99. data/test/cgi/assets/index.html +0 -1
  100. data/test/cgi/assets/javascripts/app.js +0 -1
  101. data/test/cgi/assets/stylesheets/app.css +0 -1
  102. data/test/cgi/lighttpd.conf +0 -26
  103. data/test/cgi/rackup_stub.rb +0 -6
  104. data/test/cgi/sample_rackup.ru +0 -5
  105. data/test/cgi/test +0 -9
  106. data/test/cgi/test+directory/test+file +0 -1
  107. data/test/cgi/test.fcgi +0 -9
  108. data/test/cgi/test.gz +0 -0
  109. data/test/cgi/test.ru +0 -5
  110. data/test/gemloader.rb +0 -10
  111. data/test/helper.rb +0 -34
  112. data/test/multipart/bad_robots +0 -259
  113. data/test/multipart/binary +0 -0
  114. data/test/multipart/content_type_and_no_filename +0 -6
  115. data/test/multipart/empty +0 -10
  116. data/test/multipart/fail_16384_nofile +0 -814
  117. data/test/multipart/file1.txt +0 -1
  118. data/test/multipart/filename_and_modification_param +0 -7
  119. data/test/multipart/filename_and_no_name +0 -6
  120. data/test/multipart/filename_with_encoded_words +0 -7
  121. data/test/multipart/filename_with_escaped_quotes +0 -6
  122. data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
  123. data/test/multipart/filename_with_null_byte +0 -7
  124. data/test/multipart/filename_with_percent_escaped_quotes +0 -6
  125. data/test/multipart/filename_with_single_quote +0 -7
  126. data/test/multipart/filename_with_unescaped_percentages +0 -6
  127. data/test/multipart/filename_with_unescaped_percentages2 +0 -6
  128. data/test/multipart/filename_with_unescaped_percentages3 +0 -6
  129. data/test/multipart/filename_with_unescaped_quotes +0 -6
  130. data/test/multipart/ie +0 -6
  131. data/test/multipart/invalid_character +0 -6
  132. data/test/multipart/mixed_files +0 -21
  133. data/test/multipart/nested +0 -10
  134. data/test/multipart/none +0 -9
  135. data/test/multipart/quoted +0 -15
  136. data/test/multipart/rack-logo.png +0 -0
  137. data/test/multipart/semicolon +0 -6
  138. data/test/multipart/text +0 -15
  139. data/test/multipart/three_files_three_fields +0 -31
  140. data/test/multipart/unity3d_wwwform +0 -11
  141. data/test/multipart/webkit +0 -32
  142. data/test/rackup/config.ru +0 -31
  143. data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
  144. data/test/spec_auth_basic.rb +0 -89
  145. data/test/spec_auth_digest.rb +0 -260
  146. data/test/spec_body_proxy.rb +0 -85
  147. data/test/spec_builder.rb +0 -233
  148. data/test/spec_cascade.rb +0 -63
  149. data/test/spec_cgi.rb +0 -84
  150. data/test/spec_chunked.rb +0 -103
  151. data/test/spec_common_logger.rb +0 -107
  152. data/test/spec_conditional_get.rb +0 -103
  153. data/test/spec_config.rb +0 -23
  154. data/test/spec_content_length.rb +0 -86
  155. data/test/spec_content_type.rb +0 -46
  156. data/test/spec_deflater.rb +0 -375
  157. data/test/spec_directory.rb +0 -148
  158. data/test/spec_etag.rb +0 -108
  159. data/test/spec_events.rb +0 -133
  160. data/test/spec_fastcgi.rb +0 -85
  161. data/test/spec_file.rb +0 -264
  162. data/test/spec_handler.rb +0 -57
  163. data/test/spec_head.rb +0 -46
  164. data/test/spec_lint.rb +0 -520
  165. data/test/spec_lobster.rb +0 -59
  166. data/test/spec_lock.rb +0 -204
  167. data/test/spec_logger.rb +0 -24
  168. data/test/spec_media_type.rb +0 -42
  169. data/test/spec_method_override.rb +0 -110
  170. data/test/spec_mime.rb +0 -51
  171. data/test/spec_mock.rb +0 -359
  172. data/test/spec_multipart.rb +0 -721
  173. data/test/spec_null_logger.rb +0 -21
  174. data/test/spec_recursive.rb +0 -75
  175. data/test/spec_request.rb +0 -1423
  176. data/test/spec_response.rb +0 -528
  177. data/test/spec_rewindable_input.rb +0 -128
  178. data/test/spec_runtime.rb +0 -50
  179. data/test/spec_sendfile.rb +0 -125
  180. data/test/spec_server.rb +0 -193
  181. data/test/spec_session_abstract_id.rb +0 -31
  182. data/test/spec_session_abstract_session_hash.rb +0 -45
  183. data/test/spec_session_cookie.rb +0 -442
  184. data/test/spec_session_memcache.rb +0 -357
  185. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  186. data/test/spec_session_pool.rb +0 -247
  187. data/test/spec_show_exceptions.rb +0 -93
  188. data/test/spec_show_status.rb +0 -104
  189. data/test/spec_static.rb +0 -184
  190. data/test/spec_tempfile_reaper.rb +0 -64
  191. data/test/spec_thin.rb +0 -96
  192. data/test/spec_urlmap.rb +0 -237
  193. data/test/spec_utils.rb +0 -742
  194. data/test/spec_version.rb +0 -11
  195. data/test/spec_webrick.rb +0 -206
  196. data/test/static/another/index.html +0 -1
  197. data/test/static/foo.html +0 -1
  198. data/test/static/index.html +0 -1
  199. data/test/testrequest.rb +0 -78
  200. data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
  201. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'constants'
4
+
1
5
  module Rack
2
6
  class NullLogger
3
7
  def initialize(app)
@@ -20,6 +24,11 @@ module Rack
20
24
  def warn? ; end
21
25
  def error? ; end
22
26
  def fatal? ; end
27
+ def debug! ; end
28
+ def error! ; end
29
+ def fatal! ; end
30
+ def info! ; end
31
+ def warn! ; end
23
32
  def level ; end
24
33
  def progname ; end
25
34
  def datetime_format ; end
@@ -32,6 +41,8 @@ module Rack
32
41
  def sev_threshold=(sev_threshold); end
33
42
  def close ; end
34
43
  def add(severity, message = nil, progname = nil, &block); end
44
+ def log(severity, message = nil, progname = nil, &block); end
35
45
  def <<(msg); end
46
+ def reopen(logdev = nil); end
36
47
  end
37
48
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Rack
2
4
  class QueryParser
3
- DEFAULT_SEP = /[&;] */n
5
+ DEFAULT_SEP = /[&] */n
4
6
  COMMON_SEP = { ";" => /[;] */n, ";," => /[;,] */n, "&" => /[&] */n }
5
7
 
6
8
  # ParameterTypeError is the error that is raised when incoming structural
@@ -12,31 +14,41 @@ module Rack
12
14
  # sequence.
13
15
  class InvalidParameterError < ArgumentError; end
14
16
 
15
- def self.make_default(key_space_limit, param_depth_limit)
16
- new Params, key_space_limit, param_depth_limit
17
+ # ParamsTooDeepError is the error that is raised when params are recursively
18
+ # nested over the specified limit.
19
+ class ParamsTooDeepError < RangeError; end
20
+
21
+ def self.make_default(_key_space_limit=(not_deprecated = true; nil), param_depth_limit)
22
+ unless not_deprecated
23
+ warn("`first argument `key_space limit` is deprecated and no longer has an effect. Please call with only one argument, which will be required in a future version of Rack", uplevel: 1)
24
+ end
25
+
26
+ new Params, param_depth_limit
17
27
  end
18
28
 
19
- attr_reader :key_space_limit, :param_depth_limit
29
+ attr_reader :param_depth_limit
30
+
31
+ def initialize(params_class, _key_space_limit=(not_deprecated = true; nil), param_depth_limit)
32
+ unless not_deprecated
33
+ warn("`second argument `key_space limit` is deprecated and no longer has an effect. Please call with only two arguments, which will be required in a future version of Rack", uplevel: 1)
34
+ end
20
35
 
21
- def initialize(params_class, key_space_limit, param_depth_limit)
22
36
  @params_class = params_class
23
- @key_space_limit = key_space_limit
24
37
  @param_depth_limit = param_depth_limit
25
38
  end
26
39
 
27
40
  # Stolen from Mongrel, with some small modifications:
28
- # Parses a query string by breaking it up at the '&'
29
- # and ';' characters. You can also use this to parse
30
- # cookies by changing the characters used in the second
31
- # parameter (which defaults to '&;').
32
- def parse_query(qs, d = nil, &unescaper)
41
+ # Parses a query string by breaking it up at the '&'. You can also use this
42
+ # to parse cookies by changing the characters used in the second parameter
43
+ # (which defaults to '&').
44
+ def parse_query(qs, separator = nil, &unescaper)
33
45
  unescaper ||= method(:unescape)
34
46
 
35
47
  params = make_params
36
48
 
37
- (qs || '').split(d ? (COMMON_SEP[d] || /[#{d}] */n) : DEFAULT_SEP).each do |p|
49
+ (qs || '').split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
38
50
  next if p.empty?
39
- k, v = p.split('='.freeze, 2).map!(&unescaper)
51
+ k, v = p.split('=', 2).map!(&unescaper)
40
52
 
41
53
  if cur = params[k]
42
54
  if cur.class == Array
@@ -49,7 +61,7 @@ module Rack
49
61
  end
50
62
  end
51
63
 
52
- return params.to_params_hash
64
+ return params.to_h
53
65
  end
54
66
 
55
67
  # parse_nested_query expands a query string into structural types. Supported
@@ -57,75 +69,107 @@ module Rack
57
69
  # query strings with parameters of conflicting types, in this case a
58
70
  # ParameterTypeError is raised. Users are encouraged to return a 400 in this
59
71
  # case.
60
- def parse_nested_query(qs, d = nil)
61
- return {} if qs.nil? || qs.empty?
72
+ def parse_nested_query(qs, separator = nil)
62
73
  params = make_params
63
74
 
64
- (qs || '').split(d ? (COMMON_SEP[d] || /[#{d}] */n) : DEFAULT_SEP).each do |p|
65
- k, v = p.split('='.freeze, 2).map! { |s| unescape(s) }
75
+ unless qs.nil? || qs.empty?
76
+ (qs || '').split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
77
+ k, v = p.split('=', 2).map! { |s| unescape(s) }
66
78
 
67
- normalize_params(params, k, v, param_depth_limit)
79
+ _normalize_params(params, k, v, 0)
80
+ end
68
81
  end
69
82
 
70
- return params.to_params_hash
83
+ return params.to_h
71
84
  rescue ArgumentError => e
72
- raise InvalidParameterError, e.message
85
+ raise InvalidParameterError, e.message, e.backtrace
73
86
  end
74
87
 
75
88
  # normalize_params recursively expands parameters into structural types. If
76
89
  # the structural types represented by two different parameter names are in
77
- # conflict, a ParameterTypeError is raised.
78
- def normalize_params(params, name, v, depth)
79
- raise RangeError if depth <= 0
80
-
81
- name =~ %r(\A[\[\]]*([^\[\]]+)\]*)
82
- k = $1 || ''.freeze
83
- after = $' || ''.freeze
90
+ # conflict, a ParameterTypeError is raised. The depth argument is deprecated
91
+ # and should no longer be used, it is kept for backwards compatibility with
92
+ # earlier versions of rack.
93
+ def normalize_params(params, name, v, _depth=nil)
94
+ _normalize_params(params, name, v, 0)
95
+ end
84
96
 
85
- if k.empty?
86
- if !v.nil? && name == "[]".freeze
87
- return Array(v)
97
+ private def _normalize_params(params, name, v, depth)
98
+ raise ParamsTooDeepError if depth >= param_depth_limit
99
+
100
+ if !name
101
+ # nil name, treat same as empty string (required by tests)
102
+ k = after = ''
103
+ elsif depth == 0
104
+ # Start of parsing, don't treat [] or [ at start of string specially
105
+ if start = name.index('[', 1)
106
+ # Start of parameter nesting, use part before brackets as key
107
+ k = name[0, start]
108
+ after = name[start, name.length]
88
109
  else
89
- return
110
+ # Plain parameter with no nesting
111
+ k = name
112
+ after = ''
90
113
  end
114
+ elsif name.start_with?('[]')
115
+ # Array nesting
116
+ k = '[]'
117
+ after = name[2, name.length]
118
+ elsif name.start_with?('[') && (start = name.index(']', 1))
119
+ # Hash nesting, use the part inside brackets as the key
120
+ k = name[1, start-1]
121
+ after = name[start+1, name.length]
122
+ else
123
+ # Probably malformed input, nested but not starting with [
124
+ # treat full name as key for backwards compatibility.
125
+ k = name
126
+ after = ''
91
127
  end
92
128
 
93
- if after == ''.freeze
94
- params[k] = v
95
- elsif after == "[".freeze
129
+ return if k.empty?
130
+
131
+ v ||= String.new
132
+
133
+ if after == ''
134
+ if k == '[]' && depth != 0
135
+ return [v]
136
+ else
137
+ params[k] = v
138
+ end
139
+ elsif after == "["
96
140
  params[name] = v
97
- elsif after == "[]".freeze
141
+ elsif after == "[]"
98
142
  params[k] ||= []
99
143
  raise ParameterTypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array)
100
144
  params[k] << v
101
- elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$)
102
- child_key = $1
145
+ elsif after.start_with?('[]')
146
+ # Recognize x[][y] (hash inside array) parameters
147
+ unless after[2] == '[' && after.end_with?(']') && (child_key = after[3, after.length-4]) && !child_key.empty? && !child_key.index('[') && !child_key.index(']')
148
+ # Handle other nested array parameters
149
+ child_key = after[2, after.length]
150
+ end
103
151
  params[k] ||= []
104
152
  raise ParameterTypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array)
105
153
  if params_hash_type?(params[k].last) && !params_hash_has_key?(params[k].last, child_key)
106
- normalize_params(params[k].last, child_key, v, depth - 1)
154
+ _normalize_params(params[k].last, child_key, v, depth + 1)
107
155
  else
108
- params[k] << normalize_params(make_params, child_key, v, depth - 1)
156
+ params[k] << _normalize_params(make_params, child_key, v, depth + 1)
109
157
  end
110
158
  else
111
159
  params[k] ||= make_params
112
160
  raise ParameterTypeError, "expected Hash (got #{params[k].class.name}) for param `#{k}'" unless params_hash_type?(params[k])
113
- params[k] = normalize_params(params[k], after, v, depth - 1)
161
+ params[k] = _normalize_params(params[k], after, v, depth + 1)
114
162
  end
115
163
 
116
164
  params
117
165
  end
118
166
 
119
167
  def make_params
120
- @params_class.new @key_space_limit
121
- end
122
-
123
- def new_space_limit(key_space_limit)
124
- self.class.new @params_class, key_space_limit, param_depth_limit
168
+ @params_class.new
125
169
  end
126
170
 
127
171
  def new_depth_limit(param_depth_limit)
128
- self.class.new @params_class, key_space_limit, param_depth_limit
172
+ self.class.new @params_class, param_depth_limit
129
173
  end
130
174
 
131
175
  private
@@ -135,7 +179,7 @@ module Rack
135
179
  end
136
180
 
137
181
  def params_hash_has_key?(hash, key)
138
- return false if key =~ /\[\]/
182
+ return false if /\[\]/.match?(key)
139
183
 
140
184
  key.split(/[\[\]]+/).inject(hash) do |h, part|
141
185
  next h if part == ''
@@ -151,8 +195,7 @@ module Rack
151
195
  end
152
196
 
153
197
  class Params
154
- def initialize(limit)
155
- @limit = limit
198
+ def initialize
156
199
  @size = 0
157
200
  @params = {}
158
201
  end
@@ -162,8 +205,6 @@ module Rack
162
205
  end
163
206
 
164
207
  def []=(key, value)
165
- @size += key.size if key && !@params.key?(key)
166
- raise RangeError, 'exceeded available parameter key space' if @size > @limit
167
208
  @params[key] = value
168
209
  end
169
210
 
@@ -171,22 +212,42 @@ module Rack
171
212
  @params.key?(key)
172
213
  end
173
214
 
174
- def to_params_hash
175
- hash = @params
176
- hash.keys.each do |key|
177
- value = hash[key]
178
- if value.kind_of?(self.class)
179
- if value.object_id == self.object_id
180
- hash[key] = hash
181
- else
182
- hash[key] = value.to_params_hash
183
- end
184
- elsif value.kind_of?(Array)
185
- value.map! {|x| x.kind_of?(self.class) ? x.to_params_hash : x}
215
+ # Recursively unwraps nested `Params` objects and constructs an object
216
+ # of the same shape, but using the objects' internal representations
217
+ # (Ruby hashes) in place of the objects. The result is a hash consisting
218
+ # purely of Ruby primitives.
219
+ #
220
+ # Mutation warning!
221
+ #
222
+ # 1. This method mutates the internal representation of the `Params`
223
+ # objects in order to save object allocations.
224
+ #
225
+ # 2. The value you get back is a reference to the internal hash
226
+ # representation, not a copy.
227
+ #
228
+ # 3. Because the `Params` object's internal representation is mutable
229
+ # through the `#[]=` method, it is not thread safe. The result of
230
+ # getting the hash representation while another thread is adding a
231
+ # key to it is non-deterministic.
232
+ #
233
+ def to_h
234
+ @params.each do |key, value|
235
+ case value
236
+ when self
237
+ # Handle circular references gracefully.
238
+ @params[key] = @params
239
+ when Params
240
+ @params[key] = value.to_h
241
+ when Array
242
+ value.map! { |v| v.kind_of?(Params) ? v.to_h : v }
243
+ else
244
+ # Ignore anything that is not a `Params` object or
245
+ # a collection that can contain one.
186
246
  end
187
247
  end
188
- hash
248
+ @params
189
249
  end
250
+ alias_method :to_params_hash, :to_h
190
251
  end
191
252
  end
192
253
  end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
 
5
+ require_relative 'constants'
6
+
3
7
  module Rack
4
8
  # Rack::ForwardRequest gets caught by Rack::Recursive and redirects
5
9
  # the current request to the app at +url+.
@@ -10,14 +14,14 @@ module Rack
10
14
  class ForwardRequest < Exception
11
15
  attr_reader :url, :env
12
16
 
13
- def initialize(url, env={})
17
+ def initialize(url, env = {})
14
18
  @url = URI(url)
15
19
  @env = env
16
20
 
17
- @env[PATH_INFO] = @url.path
18
- @env[QUERY_STRING] = @url.query if @url.query
19
- @env[HTTP_HOST] = @url.host if @url.host
20
- @env["HTTP_PORT"] = @url.port if @url.port
21
+ @env[PATH_INFO] = @url.path
22
+ @env[QUERY_STRING] = @url.query if @url.query
23
+ @env[HTTP_HOST] = @url.host if @url.host
24
+ @env[HTTP_PORT] = @url.port if @url.port
21
25
  @env[RACK_URL_SCHEME] = @url.scheme if @url.scheme
22
26
 
23
27
  super "forwarding to #{url}"
data/lib/rack/reloader.rb CHANGED
@@ -1,6 +1,8 @@
1
- # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
- # Rack::Reloader is subject to the terms of an MIT-style license.
3
- # See COPYING or http://www.opensource.org/licenses/mit-license.php.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2009-2018 Michael Fellinger <m.fellinger@gmail.com>
4
+ # Rack::Reloader is subject to the terms of an MIT-style license.
5
+ # See MIT-LICENSE or https://opensource.org/licenses/MIT.
4
6
 
5
7
  require 'pathname'
6
8
 
@@ -69,7 +71,7 @@ module Rack
69
71
  paths = ['./', *$LOAD_PATH].uniq
70
72
 
71
73
  files.map{|file|
72
- next if file =~ /\.(so|bundle)$/ # cannot reload compiled files
74
+ next if /\.(so|bundle)$/.match?(file) # cannot reload compiled files
73
75
 
74
76
  found, stat = figure_path(file, paths)
75
77
  next unless found && stat && mtime = stat.mtime