rack 3.0.15 → 3.2.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +368 -6
- data/CONTRIBUTING.md +11 -9
- data/README.md +103 -28
- data/SPEC.rdoc +206 -288
- data/lib/rack/auth/abstract/request.rb +2 -0
- data/lib/rack/auth/basic.rb +1 -2
- data/lib/rack/bad_request.rb +8 -0
- data/lib/rack/builder.rb +29 -10
- data/lib/rack/cascade.rb +0 -3
- data/lib/rack/conditional_get.rb +4 -3
- data/lib/rack/constants.rb +4 -0
- data/lib/rack/directory.rb +6 -3
- data/lib/rack/events.rb +21 -6
- data/lib/rack/files.rb +1 -1
- data/lib/rack/head.rb +2 -3
- data/lib/rack/headers.rb +86 -2
- data/lib/rack/lint.rb +482 -425
- data/lib/rack/media_type.rb +14 -10
- data/lib/rack/mime.rb +6 -5
- data/lib/rack/mock_request.rb +10 -15
- data/lib/rack/mock_response.rb +50 -20
- data/lib/rack/multipart/parser.rb +255 -76
- data/lib/rack/multipart/uploaded_file.rb +42 -5
- data/lib/rack/multipart.rb +34 -1
- data/lib/rack/query_parser.rb +86 -78
- data/lib/rack/request.rb +78 -65
- data/lib/rack/response.rb +28 -20
- data/lib/rack/rewindable_input.rb +4 -1
- data/lib/rack/sendfile.rb +51 -21
- data/lib/rack/show_exceptions.rb +10 -4
- data/lib/rack/show_status.rb +0 -2
- data/lib/rack/static.rb +7 -3
- data/lib/rack/utils.rb +175 -119
- data/lib/rack/version.rb +3 -20
- data/lib/rack.rb +1 -4
- metadata +6 -12
- data/lib/rack/auth/digest/md5.rb +0 -1
- data/lib/rack/auth/digest/nonce.rb +0 -1
- data/lib/rack/auth/digest/params.rb +0 -1
- data/lib/rack/auth/digest/request.rb +0 -1
- data/lib/rack/auth/digest.rb +0 -256
- data/lib/rack/chunked.rb +0 -120
- data/lib/rack/file.rb +0 -9
- data/lib/rack/logger.rb +0 -22
data/README.md
CHANGED
|
@@ -1,17 +1,55 @@
|
|
|
1
1
|
# 
|
|
2
2
|
|
|
3
|
-
> **_NOTE:_** Rack v3.0.0 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
|
|
61
|
+
$ gem install rack
|
|
24
62
|
|
|
25
63
|
# or, add it to your current application gemfile:
|
|
26
|
-
$ bundle add rack
|
|
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)
|
|
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)
|
|
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)
|
|
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
|
|
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
|
|
@@ -202,7 +275,6 @@ Can also be set via the `RACK_MULTIPART_FILE_LIMIT` environment variable.
|
|
|
202
275
|
|
|
203
276
|
(This is also aliased as `multipart_part_limit` and `RACK_MULTIPART_PART_LIMIT` for compatibility)
|
|
204
277
|
|
|
205
|
-
|
|
206
278
|
### `multipart_total_part_limit`
|
|
207
279
|
|
|
208
280
|
The maximum total number of parts a request can contain of any type, including
|
|
@@ -215,18 +287,12 @@ Set to 0 for no limit.
|
|
|
215
287
|
|
|
216
288
|
Can also be set via the `RACK_MULTIPART_TOTAL_PART_LIMIT` environment variable.
|
|
217
289
|
|
|
218
|
-
|
|
219
|
-
## Changelog
|
|
220
|
-
|
|
221
|
-
See [CHANGELOG.md](CHANGELOG.md).
|
|
222
|
-
|
|
223
290
|
## Contributing
|
|
224
291
|
|
|
225
292
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for specific details about how to make a
|
|
226
293
|
contribution to Rack.
|
|
227
294
|
|
|
228
|
-
Please post bugs, suggestions and patches to [GitHub
|
|
229
|
-
Issues](https://github.com/rack/rack/issues).
|
|
295
|
+
Please post bugs, suggestions and patches to [GitHub Issues](https://github.com/rack/rack/issues).
|
|
230
296
|
|
|
231
297
|
Please check our [Security Policy](https://github.com/rack/rack/security/policy)
|
|
232
298
|
for responsible disclosure and security bug reporting process. Due to wide usage
|
|
@@ -236,6 +302,13 @@ is greatly appreciated.
|
|
|
236
302
|
|
|
237
303
|
## See Also
|
|
238
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
|
+
|
|
239
312
|
### `rack-contrib`
|
|
240
313
|
|
|
241
314
|
The plethora of useful middleware created the need for a project that collects
|
|
@@ -306,4 +379,6 @@ would like to thank:
|
|
|
306
379
|
|
|
307
380
|
Rack is released under the [MIT License](MIT-LICENSE).
|
|
308
381
|
|
|
309
|
-
[Rack Specification]:
|
|
382
|
+
[Rack Specification]: https://rack.github.io/rack/main/SPEC_rdoc.html
|
|
383
|
+
[Documentation]: https://rack.github.io/rack/
|
|
384
|
+
[Security Policy]: SECURITY.md
|