rack 3.0.0 → 3.2.7

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +592 -1
  3. data/CONTRIBUTING.md +11 -9
  4. data/README.md +120 -29
  5. data/SPEC.rdoc +206 -288
  6. data/lib/rack/auth/abstract/request.rb +2 -0
  7. data/lib/rack/auth/basic.rb +1 -4
  8. data/lib/rack/bad_request.rb +8 -0
  9. data/lib/rack/body_proxy.rb +18 -2
  10. data/lib/rack/builder.rb +61 -40
  11. data/lib/rack/cascade.rb +0 -3
  12. data/lib/rack/common_logger.rb +3 -2
  13. data/lib/rack/conditional_get.rb +4 -3
  14. data/lib/rack/constants.rb +6 -1
  15. data/lib/rack/directory.rb +6 -3
  16. data/lib/rack/etag.rb +3 -0
  17. data/lib/rack/events.rb +21 -6
  18. data/lib/rack/files.rb +1 -1
  19. data/lib/rack/head.rb +2 -3
  20. data/lib/rack/headers.rb +98 -14
  21. data/lib/rack/lint.rb +491 -428
  22. data/lib/rack/media_type.rb +18 -9
  23. data/lib/rack/method_override.rb +2 -2
  24. data/lib/rack/mime.rb +6 -5
  25. data/lib/rack/mock_request.rb +10 -15
  26. data/lib/rack/mock_response.rb +50 -20
  27. data/lib/rack/multipart/parser.rb +279 -80
  28. data/lib/rack/multipart/uploaded_file.rb +42 -5
  29. data/lib/rack/multipart.rb +34 -1
  30. data/lib/rack/query_parser.rb +88 -80
  31. data/lib/rack/request.rb +98 -65
  32. data/lib/rack/response.rb +35 -20
  33. data/lib/rack/rewindable_input.rb +4 -1
  34. data/lib/rack/sendfile.rb +53 -23
  35. data/lib/rack/show_exceptions.rb +10 -4
  36. data/lib/rack/show_status.rb +0 -2
  37. data/lib/rack/static.rb +9 -4
  38. data/lib/rack/urlmap.rb +1 -1
  39. data/lib/rack/utils.rb +205 -133
  40. data/lib/rack/version.rb +3 -20
  41. data/lib/rack.rb +11 -17
  42. metadata +6 -15
  43. data/lib/rack/auth/digest/md5.rb +0 -1
  44. data/lib/rack/auth/digest/nonce.rb +0 -1
  45. data/lib/rack/auth/digest/params.rb +0 -1
  46. data/lib/rack/auth/digest/request.rb +0 -1
  47. data/lib/rack/auth/digest.rb +0 -256
  48. data/lib/rack/chunked.rb +0 -120
  49. data/lib/rack/file.rb +0 -9
  50. data/lib/rack/logger.rb +0 -22
data/CONTRIBUTING.md CHANGED
@@ -5,6 +5,15 @@ contributors](https://github.com/rack/rack/graphs/contributors). You're
5
5
  encouraged to submit [pull requests](https://github.com/rack/rack/pulls) and
6
6
  [propose features and discuss issues](https://github.com/rack/rack/issues).
7
7
 
8
+ ## Backports
9
+
10
+ Only security patches are ideal for backporting to non-main release versions. If
11
+ you're not sure if your bug fix is backportable, you should open a discussion to
12
+ discuss it first.
13
+
14
+ The [Security Policy] documents which release versions will receive security
15
+ backports.
16
+
8
17
  ## Fork the Project
9
18
 
10
19
  Fork the [project on GitHub](https://github.com/rack/rack) and check out your
@@ -27,15 +36,6 @@ git pull upstream main
27
36
  git checkout -b my-feature-branch
28
37
  ```
29
38
 
30
- ## Bundle Install and Quick Test
31
-
32
- Ensure that you can build the project and run quick tests.
33
-
34
- ```
35
- bundle install --without extra
36
- bundle exec rake test
37
- ```
38
-
39
39
  ## Running All Tests
40
40
 
41
41
  Install all dependencies.
@@ -140,3 +140,5 @@ there!
140
140
 
141
141
  Please do know that we really appreciate and value your time and work. We love
142
142
  you, really.
143
+
144
+ [Security Policy]: SECURITY.md
data/README.md CHANGED
@@ -1,17 +1,55 @@
1
1
  # ![Rack](contrib/logo.webp)
2
2
 
3
- > **_NOTE:_** Rack v3.0.0.beta1 was recently released. Please check the [Upgrade
4
- > Guide](UPGRADE-GUIDE.md) for more details about migrating your existing
5
- > servers, middlewares and applications. For detailed information on specific
6
- > changes, check the [Change Log](CHANGELOG.md).
7
-
8
3
  Rack provides a minimal, modular, and adaptable interface for developing web
9
4
  applications in Ruby. By wrapping HTTP requests and responses in the simplest
10
5
  way possible, it unifies and distills the bridge between web servers, web
11
6
  frameworks, and web application into a single method call.
12
7
 
13
8
  The exact details of this are described in the [Rack Specification], which all
14
- Rack applications should conform to.
9
+ Rack applications should conform to. Browse the [Documentation] for more
10
+ information.
11
+
12
+ ## Version support
13
+
14
+ | Version | Support |
15
+ |----------|------------------------------------|
16
+ | 3.2.x | Bug fixes and security patches. |
17
+ | 3.1.x | Security patches only. |
18
+ | 3.0.x | End of support. |
19
+ | 2.2.x | Security patches only. |
20
+ | <= 2.1.x | End of support. |
21
+
22
+ **Rack 2.2.x is in security maintenance mode**. Please upgrade to Rack 3.1+ as soon
23
+ as possible to ensure you are receiving the latest features and security patches.
24
+
25
+ Please see the [Security Policy] for more information.
26
+
27
+ ## Change log
28
+
29
+ See the [Changelog](CHANGELOG.md) for a detailed list of changes in each version of Rack.
30
+
31
+ ### Rack 3.2 (latest release)
32
+
33
+ This version of rack contains bug fixes and security patches.
34
+
35
+ ### Rack 3.1
36
+
37
+ This version of rack contains bug fixes and security patches.
38
+
39
+ ### Rack 3.0
40
+
41
+ This version of rack contains significant changes which are detailed in the
42
+ [Upgrade Guide](UPGRADE-GUIDE.md). It is recommended to upgrade to Rack 3 as soon
43
+ as possible to receive the latest features and security patches.
44
+
45
+ ### Rack 2.2
46
+
47
+ This version of Rack is receiving security patches only, and effort should be
48
+ made to move to Rack 3.
49
+
50
+ Starting in Ruby 3.4 the `base64` dependency will no longer be a default gem,
51
+ and may cause a warning or error about `base64` being missing. To correct this,
52
+ add `base64` as a dependency to your project.
15
53
 
16
54
  ## Installation
17
55
 
@@ -20,10 +58,10 @@ by a [supported web framework](#supported-web-frameworks):
20
58
 
21
59
  ```bash
22
60
  # Install it generally:
23
- $ gem install rack --pre
61
+ $ gem install rack
24
62
 
25
63
  # or, add it to your current application gemfile:
26
- $ bundle add rack --version 3.0.0.beta1
64
+ $ bundle add rack
27
65
  ```
28
66
 
29
67
  If you need features from `Rack::Session` or `bin/rackup` please add those gems separately.
@@ -48,6 +86,8 @@ server](#supported-web-servers).
48
86
  ```bash
49
87
  $ gem install rackup
50
88
  $ rackup
89
+
90
+ # In another shell:
51
91
  $ curl http://localhost:9292
52
92
  Hello World
53
93
  ```
@@ -57,11 +97,12 @@ Hello World
57
97
  Rack is supported by a wide range of servers, including:
58
98
 
59
99
  * [Agoo](https://github.com/ohler55/agoo)
60
- * [Falcon](https://github.com/socketry/falcon) **(Rack 3 Compatible)**
100
+ * [Falcon](https://github.com/socketry/falcon)
61
101
  * [Iodine](https://github.com/boazsegev/iodine)
62
102
  * [NGINX Unit](https://unit.nginx.org/)
63
103
  * [Phusion Passenger](https://www.phusionpassenger.com/) (which is mod_rack for
64
104
  Apache and for nginx)
105
+ * [Pitchfork](https://github.com/Shopify/pitchfork)
65
106
  * [Puma](https://puma.io/)
66
107
  * [Thin](https://github.com/macournoyer/thin)
67
108
  * [Unicorn](https://yhbt.net/unicorn/)
@@ -84,18 +125,15 @@ These frameworks and many others support the [Rack Specification]:
84
125
 
85
126
  * [Camping](https://github.com/camping/camping)
86
127
  * [Hanami](https://hanamirb.org/)
128
+ * [Ramaze](https://github.com/ramaze/ramaze)
87
129
  * [Padrino](https://padrinorb.com/)
88
- * [Roda](https://github.com/jeremyevans/roda) **(Rack 3 Compatible)**
130
+ * [Roda](https://github.com/jeremyevans/roda)
89
131
  * [Ruby on Rails](https://rubyonrails.org/)
132
+ * [Rum](https://github.com/leahneukirchen/rum)
90
133
  * [Sinatra](https://sinatrarb.com/)
91
- * [Utopia](https://github.com/socketry/utopia) **(Rack 3 Compatible)**
134
+ * [Utopia](https://github.com/socketry/utopia)
92
135
  * [WABuR](https://github.com/ohler55/wabur)
93
136
 
94
- ### Older (possibly unsupported) web frameworks
95
-
96
- * [Ramaze](http://ramaze.net/)
97
- * [Rum](https://github.com/leahneukirchen/rum)
98
-
99
137
  ## Available middleware shipped with Rack
100
138
 
101
139
  Between the server and the framework, Rack can be customized to your
@@ -114,11 +152,9 @@ middleware:
114
152
  * `Rack::ETag` for setting `etag` header on bodies that can be buffered.
115
153
  * `Rack::Events` for providing easy hooks when a request is received and when
116
154
  the response is sent.
117
- * `Rack::Files` for serving static files.
118
155
  * `Rack::Head` for returning an empty body for HEAD requests.
119
156
  * `Rack::Lint` for checking conformance to the [Rack Specification].
120
157
  * `Rack::Lock` for serializing requests using a mutex.
121
- * `Rack::Logger` for setting a logger to handle logging errors.
122
158
  * `Rack::MethodOverride` for modifying the request method based on a submitted
123
159
  parameter.
124
160
  * `Rack::Recursive` for including data from other paths in the application, and
@@ -132,7 +168,7 @@ middleware:
132
168
  a nice and helpful way with clickable backtrace.
133
169
  * `Rack::ShowStatus` for using nice error pages for empty client error
134
170
  responses.
135
- * `Rack::Static` for more configurable serving of static files.
171
+ * `Rack::Static` for configurable serving of static files.
136
172
  * `Rack::TempfileReaper` for removing temporary files creating during a request.
137
173
 
138
174
  All these components use the same interface, which is described in detail in the
@@ -154,6 +190,8 @@ quickly and without doing the same web stuff all over:
154
190
  returns a not found or method not supported response.
155
191
  * `Rack::Directory` for serving files under a given directory, with directory
156
192
  indexes.
193
+ * `Rack::Files` for serving files under a given directory, without directory
194
+ indexes.
157
195
  * `Rack::MediaType` for parsing content-type headers.
158
196
  * `Rack::Mime` for determining content-type based on file extension.
159
197
  * `Rack::RewindableInput` for making any IO object rewindable, using a temporary
@@ -165,6 +203,41 @@ quickly and without doing the same web stuff all over:
165
203
  Rack exposes several configuration parameters to control various features of the
166
204
  implementation.
167
205
 
206
+ ### `RACK_QUERY_PARSER_BYTESIZE_LIMIT`
207
+
208
+ This environment variable sets the default for the maximum query string bytesize
209
+ that `Rack::QueryParser` will attempt to parse. Attempts to use a query string
210
+ that exceeds this number of bytes will result in a
211
+ `Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
212
+ provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
213
+
214
+ The default limit can be overridden on a per-`Rack::QueryParser` basis using
215
+ the `bytesize_limit` keyword argument when creating the `Rack::QueryParser`.
216
+
217
+ ### `RACK_QUERY_PARSER_PARAMS_LIMIT`
218
+
219
+ This environment variable sets the default for the maximum number of query
220
+ parameters that `Rack::QueryParser` will attempt to parse. Attempts to use a
221
+ query string with more than this many query parameters will result in a
222
+ `Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
223
+ provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
224
+
225
+ The default limit can be overridden on a per-`Rack::QueryParser` basis using
226
+ the `params_limit` keyword argument when creating the `Rack::QueryParser`.
227
+
228
+ This is implemented by counting the number of parameter separators in the
229
+ query string, before attempting parsing, so if the same parameter key is
230
+ used multiple times in the query, each counts as a separate parameter for
231
+ this check.
232
+
233
+ ### `RACK_MULTIPART_BUFFERED_UPLOAD_BYTESIZE_LIMIT`
234
+
235
+ This environment variable sets the maximum amount of memory Rack will use
236
+ to buffer multipart parameters when parsing a request body. This considers
237
+ the size of the multipart mime headers and the body part for multipart
238
+ parameters that are buffered in memory and do not use tempfiles. This
239
+ defaults to 16MB if not provided.
240
+
168
241
  ### `param_depth_limit`
169
242
 
170
243
  ```ruby
@@ -186,31 +259,40 @@ but this query string would not be allowed:
186
259
 
187
260
  Limiting the depth prevents a possible stack overflow when parsing parameters.
188
261
 
189
- ### `multipart_part_limit`
262
+ ### `multipart_file_limit`
190
263
 
191
264
  ```ruby
192
- Rack::Utils.multipart_part_limit = 128 # default
265
+ Rack::Utils.multipart_file_limit = 128 # default
193
266
  ```
194
267
 
195
- The maximum number of parts a request can contain. Accepting too many parts can
196
- lead to the server running out of file handles.
268
+ The maximum number of parts with a filename a request can contain. Accepting
269
+ too many parts can lead to the server running out of file handles.
197
270
 
198
271
  The default is 128, which means that a single request can't upload more than 128
199
272
  files at once. Set to 0 for no limit.
200
273
 
201
- Can also be set via the `RACK_MULTIPART_PART_LIMIT` environment variable.
274
+ Can also be set via the `RACK_MULTIPART_FILE_LIMIT` environment variable.
275
+
276
+ (This is also aliased as `multipart_part_limit` and `RACK_MULTIPART_PART_LIMIT` for compatibility)
277
+
278
+ ### `multipart_total_part_limit`
279
+
280
+ The maximum total number of parts a request can contain of any type, including
281
+ both file and non-file form fields.
202
282
 
203
- ## Changelog
283
+ The default is 4096, which means that a single request can't contain more than
284
+ 4096 parts.
204
285
 
205
- See [CHANGELOG.md](CHANGELOG.md).
286
+ Set to 0 for no limit.
287
+
288
+ Can also be set via the `RACK_MULTIPART_TOTAL_PART_LIMIT` environment variable.
206
289
 
207
290
  ## Contributing
208
291
 
209
292
  See [CONTRIBUTING.md](CONTRIBUTING.md) for specific details about how to make a
210
293
  contribution to Rack.
211
294
 
212
- Please post bugs, suggestions and patches to [GitHub
213
- Issues](https://github.com/rack/rack/issues).
295
+ Please post bugs, suggestions and patches to [GitHub Issues](https://github.com/rack/rack/issues).
214
296
 
215
297
  Please check our [Security Policy](https://github.com/rack/rack/security/policy)
216
298
  for responsible disclosure and security bug reporting process. Due to wide usage
@@ -220,6 +302,13 @@ is greatly appreciated.
220
302
 
221
303
  ## See Also
222
304
 
305
+ ### `rackup`
306
+
307
+ A useful tool for running Rack applications from the command line, including
308
+ `Rackup::Server` (previously `Rack::Server`) for scripting servers.
309
+
310
+ * https://github.com/rack/rackup
311
+
223
312
  ### `rack-contrib`
224
313
 
225
314
  The plethora of useful middleware created the need for a project that collects
@@ -290,4 +379,6 @@ would like to thank:
290
379
 
291
380
  Rack is released under the [MIT License](MIT-LICENSE).
292
381
 
293
- [Rack Specification]: SPEC.rdoc
382
+ [Rack Specification]: https://rack.github.io/rack/main/SPEC_rdoc.html
383
+ [Documentation]: https://rack.github.io/rack/
384
+ [Security Policy]: SECURITY.md