rack 2.2.6.4 → 3.0.8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +205 -80
- data/CONTRIBUTING.md +53 -47
- data/MIT-LICENSE +1 -1
- data/README.md +309 -0
- data/SPEC.rdoc +183 -131
- data/lib/rack/auth/abstract/handler.rb +3 -1
- data/lib/rack/auth/abstract/request.rb +3 -1
- data/lib/rack/auth/basic.rb +0 -2
- data/lib/rack/auth/digest/md5.rb +1 -131
- data/lib/rack/auth/digest/nonce.rb +1 -54
- data/lib/rack/auth/digest/params.rb +1 -54
- data/lib/rack/auth/digest/request.rb +1 -43
- data/lib/rack/auth/digest.rb +256 -0
- data/lib/rack/body_proxy.rb +3 -1
- data/lib/rack/builder.rb +83 -63
- data/lib/rack/cascade.rb +2 -0
- data/lib/rack/chunked.rb +16 -13
- data/lib/rack/common_logger.rb +23 -18
- data/lib/rack/conditional_get.rb +18 -15
- data/lib/rack/constants.rb +64 -0
- data/lib/rack/content_length.rb +12 -16
- data/lib/rack/content_type.rb +8 -5
- data/lib/rack/deflater.rb +40 -26
- data/lib/rack/directory.rb +9 -3
- data/lib/rack/etag.rb +14 -23
- data/lib/rack/events.rb +4 -0
- data/lib/rack/file.rb +2 -0
- data/lib/rack/files.rb +15 -17
- data/lib/rack/head.rb +9 -8
- data/lib/rack/headers.rb +154 -0
- data/lib/rack/lint.rb +783 -682
- data/lib/rack/lock.rb +2 -5
- data/lib/rack/logger.rb +2 -0
- data/lib/rack/media_type.rb +1 -1
- data/lib/rack/method_override.rb +5 -1
- data/lib/rack/mime.rb +8 -0
- data/lib/rack/mock.rb +1 -271
- data/lib/rack/mock_request.rb +166 -0
- data/lib/rack/mock_response.rb +126 -0
- data/lib/rack/multipart/generator.rb +7 -5
- data/lib/rack/multipart/parser.rb +119 -61
- data/lib/rack/multipart/uploaded_file.rb +4 -0
- data/lib/rack/multipart.rb +20 -40
- data/lib/rack/null_logger.rb +9 -0
- data/lib/rack/query_parser.rb +78 -46
- data/lib/rack/recursive.rb +2 -0
- data/lib/rack/reloader.rb +0 -2
- data/lib/rack/request.rb +224 -106
- data/lib/rack/response.rb +136 -61
- data/lib/rack/rewindable_input.rb +24 -5
- data/lib/rack/runtime.rb +7 -6
- data/lib/rack/sendfile.rb +30 -25
- data/lib/rack/show_exceptions.rb +15 -2
- data/lib/rack/show_status.rb +17 -7
- data/lib/rack/static.rb +8 -8
- data/lib/rack/tempfile_reaper.rb +15 -4
- data/lib/rack/urlmap.rb +3 -1
- data/lib/rack/utils.rb +202 -176
- data/lib/rack/version.rb +9 -4
- data/lib/rack.rb +6 -76
- metadata +18 -38
- data/README.rdoc +0 -320
- data/Rakefile +0 -130
- data/bin/rackup +0 -5
- data/contrib/rack.png +0 -0
- data/contrib/rack.svg +0 -150
- data/contrib/rack_logo.svg +0 -164
- data/contrib/rdoc.css +0 -412
- data/example/lobster.ru +0 -6
- data/example/protectedlobster.rb +0 -16
- data/example/protectedlobster.ru +0 -10
- data/lib/rack/core_ext/regexp.rb +0 -14
- data/lib/rack/handler/cgi.rb +0 -59
- data/lib/rack/handler/fastcgi.rb +0 -100
- data/lib/rack/handler/lsws.rb +0 -61
- data/lib/rack/handler/scgi.rb +0 -71
- data/lib/rack/handler/thin.rb +0 -36
- data/lib/rack/handler/webrick.rb +0 -129
- data/lib/rack/handler.rb +0 -104
- data/lib/rack/lobster.rb +0 -70
- data/lib/rack/server.rb +0 -466
- data/lib/rack/session/abstract/id.rb +0 -523
- data/lib/rack/session/cookie.rb +0 -203
- data/lib/rack/session/memcache.rb +0 -10
- data/lib/rack/session/pool.rb +0 -85
- data/rack.gemspec +0 -46
data/MIT-LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (C) 2007-
|
3
|
+
Copyright (C) 2007-2021 Leah Neukirchen <http://leahneukirchen.org/infopage.html>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to
|
data/README.md
ADDED
@@ -0,0 +1,309 @@
|
|
1
|
+
# ![Rack](contrib/logo.webp)
|
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
|
+
Rack provides a minimal, modular, and adaptable interface for developing web
|
9
|
+
applications in Ruby. By wrapping HTTP requests and responses in the simplest
|
10
|
+
way possible, it unifies and distills the bridge between web servers, web
|
11
|
+
frameworks, and web application into a single method call.
|
12
|
+
|
13
|
+
The exact details of this are described in the [Rack Specification], which all
|
14
|
+
Rack applications should conform to.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add the rack gem to your application bundle, or follow the instructions provided
|
19
|
+
by a [supported web framework](#supported-web-frameworks):
|
20
|
+
|
21
|
+
```bash
|
22
|
+
# Install it generally:
|
23
|
+
$ gem install rack --pre
|
24
|
+
|
25
|
+
# or, add it to your current application gemfile:
|
26
|
+
$ bundle add rack --version 3.0.0
|
27
|
+
```
|
28
|
+
|
29
|
+
If you need features from `Rack::Session` or `bin/rackup` please add those gems separately.
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ gem install rack-session rackup
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
Create a file called `config.ru` with the following contents:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
run do |env|
|
41
|
+
[200, {}, ["Hello World"]]
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
Run this using the rackup gem or another [supported web
|
46
|
+
server](#supported-web-servers).
|
47
|
+
|
48
|
+
```bash
|
49
|
+
$ gem install rackup
|
50
|
+
$ rackup
|
51
|
+
$ curl http://localhost:9292
|
52
|
+
Hello World
|
53
|
+
```
|
54
|
+
|
55
|
+
## Supported web servers
|
56
|
+
|
57
|
+
Rack is supported by a wide range of servers, including:
|
58
|
+
|
59
|
+
* [Agoo](https://github.com/ohler55/agoo)
|
60
|
+
* [Falcon](https://github.com/socketry/falcon) **(Rack 3 Compatible)**
|
61
|
+
* [Iodine](https://github.com/boazsegev/iodine)
|
62
|
+
* [NGINX Unit](https://unit.nginx.org/)
|
63
|
+
* [Phusion Passenger](https://www.phusionpassenger.com/) (which is mod_rack for
|
64
|
+
Apache and for nginx)
|
65
|
+
* [Puma](https://puma.io/)
|
66
|
+
* [Thin](https://github.com/macournoyer/thin)
|
67
|
+
* [Unicorn](https://yhbt.net/unicorn/)
|
68
|
+
* [uWSGI](https://uwsgi-docs.readthedocs.io/en/latest/)
|
69
|
+
* [Lamby](https://lamby.custominktech.com) (for AWS Lambda)
|
70
|
+
|
71
|
+
You will need to consult the server documentation to find out what features and
|
72
|
+
limitations they may have. In general, any valid Rack app will run the same on
|
73
|
+
all these servers, without changing anything.
|
74
|
+
|
75
|
+
### Rackup
|
76
|
+
|
77
|
+
Rack provides a separate gem, [rackup](https://github.com/rack/rackup) which is
|
78
|
+
a generic interface for running a Rack application on supported servers, which
|
79
|
+
include `WEBRick`, `Puma`, `Falcon` and others.
|
80
|
+
|
81
|
+
## Supported web frameworks
|
82
|
+
|
83
|
+
These frameworks and many others support the [Rack Specification]:
|
84
|
+
|
85
|
+
* [Camping](https://github.com/camping/camping)
|
86
|
+
* [Hanami](https://hanamirb.org/)
|
87
|
+
* [Padrino](https://padrinorb.com/)
|
88
|
+
* [Roda](https://github.com/jeremyevans/roda) **(Rack 3 Compatible)**
|
89
|
+
* [Ruby on Rails](https://rubyonrails.org/)
|
90
|
+
* [Sinatra](https://sinatrarb.com/)
|
91
|
+
* [Utopia](https://github.com/socketry/utopia) **(Rack 3 Compatible)**
|
92
|
+
* [WABuR](https://github.com/ohler55/wabur)
|
93
|
+
|
94
|
+
### Older (possibly unsupported) web frameworks
|
95
|
+
|
96
|
+
* [Ramaze](http://ramaze.net/)
|
97
|
+
* [Rum](https://github.com/leahneukirchen/rum)
|
98
|
+
|
99
|
+
## Available middleware shipped with Rack
|
100
|
+
|
101
|
+
Between the server and the framework, Rack can be customized to your
|
102
|
+
applications needs using middleware. Rack itself ships with the following
|
103
|
+
middleware:
|
104
|
+
|
105
|
+
* `Rack::CommonLogger` for creating Apache-style logfiles.
|
106
|
+
* `Rack::ConditionalGet` for returning [Not
|
107
|
+
Modified](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304)
|
108
|
+
responses when the response has not changed.
|
109
|
+
* `Rack::Config` for modifying the environment before processing the request.
|
110
|
+
* `Rack::ContentLength` for setting a `content-length` header based on body
|
111
|
+
size.
|
112
|
+
* `Rack::ContentType` for setting a default `content-type` header for responses.
|
113
|
+
* `Rack::Deflater` for compressing responses with gzip.
|
114
|
+
* `Rack::ETag` for setting `etag` header on bodies that can be buffered.
|
115
|
+
* `Rack::Events` for providing easy hooks when a request is received and when
|
116
|
+
the response is sent.
|
117
|
+
* `Rack::Files` for serving static files.
|
118
|
+
* `Rack::Head` for returning an empty body for HEAD requests.
|
119
|
+
* `Rack::Lint` for checking conformance to the [Rack Specification].
|
120
|
+
* `Rack::Lock` for serializing requests using a mutex.
|
121
|
+
* `Rack::Logger` for setting a logger to handle logging errors.
|
122
|
+
* `Rack::MethodOverride` for modifying the request method based on a submitted
|
123
|
+
parameter.
|
124
|
+
* `Rack::Recursive` for including data from other paths in the application, and
|
125
|
+
for performing internal redirects.
|
126
|
+
* `Rack::Reloader` for reloading files if they have been modified.
|
127
|
+
* `Rack::Runtime` for including a response header with the time taken to process
|
128
|
+
the request.
|
129
|
+
* `Rack::Sendfile` for working with web servers that can use optimized file
|
130
|
+
serving for file system paths.
|
131
|
+
* `Rack::ShowException` for catching unhandled exceptions and presenting them in
|
132
|
+
a nice and helpful way with clickable backtrace.
|
133
|
+
* `Rack::ShowStatus` for using nice error pages for empty client error
|
134
|
+
responses.
|
135
|
+
* `Rack::Static` for more configurable serving of static files.
|
136
|
+
* `Rack::TempfileReaper` for removing temporary files creating during a request.
|
137
|
+
|
138
|
+
All these components use the same interface, which is described in detail in the
|
139
|
+
[Rack Specification]. These optional components can be used in any way you wish.
|
140
|
+
|
141
|
+
### Convenience interfaces
|
142
|
+
|
143
|
+
If you want to develop outside of existing frameworks, implement your own ones,
|
144
|
+
or develop middleware, Rack provides many helpers to create Rack applications
|
145
|
+
quickly and without doing the same web stuff all over:
|
146
|
+
|
147
|
+
* `Rack::Request` which also provides query string parsing and multipart
|
148
|
+
handling.
|
149
|
+
* `Rack::Response` for convenient generation of HTTP replies and cookie
|
150
|
+
handling.
|
151
|
+
* `Rack::MockRequest` and `Rack::MockResponse` for efficient and quick testing
|
152
|
+
of Rack application without real HTTP round-trips.
|
153
|
+
* `Rack::Cascade` for trying additional Rack applications if an application
|
154
|
+
returns a not found or method not supported response.
|
155
|
+
* `Rack::Directory` for serving files under a given directory, with directory
|
156
|
+
indexes.
|
157
|
+
* `Rack::MediaType` for parsing content-type headers.
|
158
|
+
* `Rack::Mime` for determining content-type based on file extension.
|
159
|
+
* `Rack::RewindableInput` for making any IO object rewindable, using a temporary
|
160
|
+
file buffer.
|
161
|
+
* `Rack::URLMap` to route to multiple applications inside the same process.
|
162
|
+
|
163
|
+
## Configuration
|
164
|
+
|
165
|
+
Rack exposes several configuration parameters to control various features of the
|
166
|
+
implementation.
|
167
|
+
|
168
|
+
### `param_depth_limit`
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
Rack::Utils.param_depth_limit = 32 # default
|
172
|
+
```
|
173
|
+
|
174
|
+
The maximum amount of nesting allowed in parameters. For example, if set to 3,
|
175
|
+
this query string would be allowed:
|
176
|
+
|
177
|
+
```
|
178
|
+
?a[b][c]=d
|
179
|
+
```
|
180
|
+
|
181
|
+
but this query string would not be allowed:
|
182
|
+
|
183
|
+
```
|
184
|
+
?a[b][c][d]=e
|
185
|
+
```
|
186
|
+
|
187
|
+
Limiting the depth prevents a possible stack overflow when parsing parameters.
|
188
|
+
|
189
|
+
### `multipart_file_limit`
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
Rack::Utils.multipart_file_limit = 128 # default
|
193
|
+
```
|
194
|
+
|
195
|
+
The maximum number of parts with a filename a request can contain. Accepting
|
196
|
+
too many parts can lead to the server running out of file handles.
|
197
|
+
|
198
|
+
The default is 128, which means that a single request can't upload more than 128
|
199
|
+
files at once. Set to 0 for no limit.
|
200
|
+
|
201
|
+
Can also be set via the `RACK_MULTIPART_FILE_LIMIT` environment variable.
|
202
|
+
|
203
|
+
(This is also aliased as `multipart_part_limit` and `RACK_MULTIPART_PART_LIMIT` for compatibility)
|
204
|
+
|
205
|
+
|
206
|
+
### `multipart_total_part_limit`
|
207
|
+
|
208
|
+
The maximum total number of parts a request can contain of any type, including
|
209
|
+
both file and non-file form fields.
|
210
|
+
|
211
|
+
The default is 4096, which means that a single request can't contain more than
|
212
|
+
4096 parts.
|
213
|
+
|
214
|
+
Set to 0 for no limit.
|
215
|
+
|
216
|
+
Can also be set via the `RACK_MULTIPART_TOTAL_PART_LIMIT` environment variable.
|
217
|
+
|
218
|
+
|
219
|
+
## Changelog
|
220
|
+
|
221
|
+
See [CHANGELOG.md](CHANGELOG.md).
|
222
|
+
|
223
|
+
## Contributing
|
224
|
+
|
225
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for specific details about how to make a
|
226
|
+
contribution to Rack.
|
227
|
+
|
228
|
+
Please post bugs, suggestions and patches to [GitHub
|
229
|
+
Issues](https://github.com/rack/rack/issues).
|
230
|
+
|
231
|
+
Please check our [Security Policy](https://github.com/rack/rack/security/policy)
|
232
|
+
for responsible disclosure and security bug reporting process. Due to wide usage
|
233
|
+
of the library, it is strongly preferred that we manage timing in order to
|
234
|
+
provide viable patches at the time of disclosure. Your assistance in this matter
|
235
|
+
is greatly appreciated.
|
236
|
+
|
237
|
+
## See Also
|
238
|
+
|
239
|
+
### `rack-contrib`
|
240
|
+
|
241
|
+
The plethora of useful middleware created the need for a project that collects
|
242
|
+
fresh Rack middleware. `rack-contrib` includes a variety of add-on components
|
243
|
+
for Rack and it is easy to contribute new modules.
|
244
|
+
|
245
|
+
* https://github.com/rack/rack-contrib
|
246
|
+
|
247
|
+
### `rack-session`
|
248
|
+
|
249
|
+
Provides convenient session management for Rack.
|
250
|
+
|
251
|
+
* https://github.com/rack/rack-session
|
252
|
+
|
253
|
+
## Thanks
|
254
|
+
|
255
|
+
The Rack Core Team, consisting of
|
256
|
+
|
257
|
+
* Aaron Patterson [tenderlove](https://github.com/tenderlove)
|
258
|
+
* Samuel Williams [ioquatix](https://github.com/ioquatix)
|
259
|
+
* Jeremy Evans [jeremyevans](https://github.com/jeremyevans)
|
260
|
+
* Eileen Uchitelle [eileencodes](https://github.com/eileencodes)
|
261
|
+
* Matthew Draper [matthewd](https://github.com/matthewd)
|
262
|
+
* Rafael França [rafaelfranca](https://github.com/rafaelfranca)
|
263
|
+
|
264
|
+
and the Rack Alumni
|
265
|
+
|
266
|
+
* Ryan Tomayko [rtomayko](https://github.com/rtomayko)
|
267
|
+
* Scytrin dai Kinthra [scytrin](https://github.com/scytrin)
|
268
|
+
* Leah Neukirchen [leahneukirchen](https://github.com/leahneukirchen)
|
269
|
+
* James Tucker [raggi](https://github.com/raggi)
|
270
|
+
* Josh Peek [josh](https://github.com/josh)
|
271
|
+
* José Valim [josevalim](https://github.com/josevalim)
|
272
|
+
* Michael Fellinger [manveru](https://github.com/manveru)
|
273
|
+
* Santiago Pastorino [spastorino](https://github.com/spastorino)
|
274
|
+
* Konstantin Haase [rkh](https://github.com/rkh)
|
275
|
+
|
276
|
+
would like to thank:
|
277
|
+
|
278
|
+
* Adrian Madrid, for the LiteSpeed handler.
|
279
|
+
* Christoffer Sawicki, for the first Rails adapter and `Rack::Deflater`.
|
280
|
+
* Tim Fletcher, for the HTTP authentication code.
|
281
|
+
* Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
|
282
|
+
* Armin Ronacher, for the logo and racktools.
|
283
|
+
* Alex Beregszaszi, Alexander Kahn, Anil Wadghule, Aredridel, Ben Alpert, Dan
|
284
|
+
Kubb, Daniel Roethlisberger, Matt Todd, Tom Robinson, Phil Hagelberg, S. Brent
|
285
|
+
Faulkner, Bosko Milekic, Daniel Rodríguez Troitiño, Genki Takiuchi, Geoffrey
|
286
|
+
Grosenbach, Julien Sanchez, Kamal Fariz Mahyuddin, Masayoshi Takahashi,
|
287
|
+
Patrick Aljordm, Mig, Kazuhiro Nishiyama, Jon Bardin, Konstantin Haase, Larry
|
288
|
+
Siden, Matias Korhonen, Sam Ruby, Simon Chiang, Tim Connor, Timur Batyrshin,
|
289
|
+
and Zach Brock for bug fixing and other improvements.
|
290
|
+
* Eric Wong, Hongli Lai, Jeremy Kemper for their continuous support and API
|
291
|
+
improvements.
|
292
|
+
* Yehuda Katz and Carl Lerche for refactoring rackup.
|
293
|
+
* Brian Candler, for `Rack::ContentType`.
|
294
|
+
* Graham Batty, for improved handler loading.
|
295
|
+
* Stephen Bannasch, for bug reports and documentation.
|
296
|
+
* Gary Wright, for proposing a better `Rack::Response` interface.
|
297
|
+
* Jonathan Buch, for improvements regarding `Rack::Response`.
|
298
|
+
* Armin Röhrl, for tracking down bugs in the Cookie generator.
|
299
|
+
* Alexander Kellett for testing the Gem and reviewing the announcement.
|
300
|
+
* Marcus Rückert, for help with configuring and debugging lighttpd.
|
301
|
+
* The WSGI team for the well-done and documented work they've done and Rack
|
302
|
+
builds up on.
|
303
|
+
* All bug reporters and patch contributors not mentioned above.
|
304
|
+
|
305
|
+
## License
|
306
|
+
|
307
|
+
Rack is released under the [MIT License](MIT-LICENSE).
|
308
|
+
|
309
|
+
[Rack Specification]: SPEC.rdoc
|