rack 2.2.3.1 → 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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +178 -69
  3. data/CONTRIBUTING.md +53 -47
  4. data/MIT-LICENSE +1 -1
  5. data/README.md +293 -0
  6. data/SPEC.rdoc +183 -131
  7. data/lib/rack/auth/abstract/handler.rb +3 -1
  8. data/lib/rack/auth/abstract/request.rb +3 -1
  9. data/lib/rack/auth/digest/md5.rb +1 -131
  10. data/lib/rack/auth/digest/nonce.rb +1 -54
  11. data/lib/rack/auth/digest/params.rb +1 -54
  12. data/lib/rack/auth/digest/request.rb +1 -43
  13. data/lib/rack/auth/digest.rb +256 -0
  14. data/lib/rack/body_proxy.rb +3 -1
  15. data/lib/rack/builder.rb +60 -42
  16. data/lib/rack/cascade.rb +2 -0
  17. data/lib/rack/chunked.rb +16 -13
  18. data/lib/rack/common_logger.rb +23 -18
  19. data/lib/rack/conditional_get.rb +18 -15
  20. data/lib/rack/constants.rb +63 -0
  21. data/lib/rack/content_length.rb +12 -16
  22. data/lib/rack/content_type.rb +8 -5
  23. data/lib/rack/deflater.rb +40 -26
  24. data/lib/rack/directory.rb +9 -3
  25. data/lib/rack/etag.rb +14 -21
  26. data/lib/rack/events.rb +4 -0
  27. data/lib/rack/file.rb +2 -0
  28. data/lib/rack/files.rb +15 -17
  29. data/lib/rack/head.rb +9 -8
  30. data/lib/rack/headers.rb +154 -0
  31. data/lib/rack/lint.rb +779 -684
  32. data/lib/rack/lock.rb +2 -5
  33. data/lib/rack/logger.rb +2 -0
  34. data/lib/rack/media_type.rb +1 -1
  35. data/lib/rack/method_override.rb +4 -0
  36. data/lib/rack/mime.rb +8 -0
  37. data/lib/rack/mock.rb +1 -271
  38. data/lib/rack/mock_request.rb +166 -0
  39. data/lib/rack/mock_response.rb +126 -0
  40. data/lib/rack/multipart/generator.rb +7 -5
  41. data/lib/rack/multipart/parser.rb +118 -61
  42. data/lib/rack/multipart/uploaded_file.rb +4 -0
  43. data/lib/rack/multipart.rb +20 -40
  44. data/lib/rack/null_logger.rb +9 -0
  45. data/lib/rack/query_parser.rb +80 -44
  46. data/lib/rack/recursive.rb +2 -0
  47. data/lib/rack/reloader.rb +0 -2
  48. data/lib/rack/request.rb +187 -89
  49. data/lib/rack/response.rb +131 -61
  50. data/lib/rack/rewindable_input.rb +24 -5
  51. data/lib/rack/runtime.rb +7 -6
  52. data/lib/rack/sendfile.rb +30 -25
  53. data/lib/rack/show_exceptions.rb +15 -2
  54. data/lib/rack/show_status.rb +17 -7
  55. data/lib/rack/static.rb +8 -8
  56. data/lib/rack/tempfile_reaper.rb +15 -4
  57. data/lib/rack/urlmap.rb +3 -1
  58. data/lib/rack/utils.rb +199 -170
  59. data/lib/rack/version.rb +9 -4
  60. data/lib/rack.rb +5 -76
  61. metadata +18 -38
  62. data/README.rdoc +0 -306
  63. data/Rakefile +0 -130
  64. data/bin/rackup +0 -5
  65. data/contrib/rack.png +0 -0
  66. data/contrib/rack.svg +0 -150
  67. data/contrib/rack_logo.svg +0 -164
  68. data/contrib/rdoc.css +0 -412
  69. data/example/lobster.ru +0 -6
  70. data/example/protectedlobster.rb +0 -16
  71. data/example/protectedlobster.ru +0 -10
  72. data/lib/rack/core_ext/regexp.rb +0 -14
  73. data/lib/rack/handler/cgi.rb +0 -59
  74. data/lib/rack/handler/fastcgi.rb +0 -100
  75. data/lib/rack/handler/lsws.rb +0 -61
  76. data/lib/rack/handler/scgi.rb +0 -71
  77. data/lib/rack/handler/thin.rb +0 -36
  78. data/lib/rack/handler/webrick.rb +0 -129
  79. data/lib/rack/handler.rb +0 -104
  80. data/lib/rack/lobster.rb +0 -70
  81. data/lib/rack/server.rb +0 -466
  82. data/lib/rack/session/abstract/id.rb +0 -523
  83. data/lib/rack/session/cookie.rb +0 -203
  84. data/lib/rack/session/memcache.rb +0 -10
  85. data/lib/rack/session/pool.rb +0 -85
  86. data/rack.gemspec +0 -46
data/README.md ADDED
@@ -0,0 +1,293 @@
1
+ # ![Rack](contrib/logo.webp)
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
+ 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.beta1
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_part_limit`
190
+
191
+ ```ruby
192
+ Rack::Utils.multipart_part_limit = 128 # default
193
+ ```
194
+
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.
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_PART_LIMIT` environment variable.
202
+
203
+ ## Changelog
204
+
205
+ See [CHANGELOG.md](CHANGELOG.md).
206
+
207
+ ## Contributing
208
+
209
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for specific details about how to make a
210
+ contribution to Rack.
211
+
212
+ Please post bugs, suggestions and patches to [GitHub
213
+ Issues](https://github.com/rack/rack/issues).
214
+
215
+ Please check our [Security Policy](https://github.com/rack/rack/security/policy)
216
+ for responsible disclosure and security bug reporting process. Due to wide usage
217
+ of the library, it is strongly preferred that we manage timing in order to
218
+ provide viable patches at the time of disclosure. Your assistance in this matter
219
+ is greatly appreciated.
220
+
221
+ ## See Also
222
+
223
+ ### `rack-contrib`
224
+
225
+ The plethora of useful middleware created the need for a project that collects
226
+ fresh Rack middleware. `rack-contrib` includes a variety of add-on components
227
+ for Rack and it is easy to contribute new modules.
228
+
229
+ * https://github.com/rack/rack-contrib
230
+
231
+ ### `rack-session`
232
+
233
+ Provides convenient session management for Rack.
234
+
235
+ * https://github.com/rack/rack-session
236
+
237
+ ## Thanks
238
+
239
+ The Rack Core Team, consisting of
240
+
241
+ * Aaron Patterson [tenderlove](https://github.com/tenderlove)
242
+ * Samuel Williams [ioquatix](https://github.com/ioquatix)
243
+ * Jeremy Evans [jeremyevans](https://github.com/jeremyevans)
244
+ * Eileen Uchitelle [eileencodes](https://github.com/eileencodes)
245
+ * Matthew Draper [matthewd](https://github.com/matthewd)
246
+ * Rafael França [rafaelfranca](https://github.com/rafaelfranca)
247
+
248
+ and the Rack Alumni
249
+
250
+ * Ryan Tomayko [rtomayko](https://github.com/rtomayko)
251
+ * Scytrin dai Kinthra [scytrin](https://github.com/scytrin)
252
+ * Leah Neukirchen [leahneukirchen](https://github.com/leahneukirchen)
253
+ * James Tucker [raggi](https://github.com/raggi)
254
+ * Josh Peek [josh](https://github.com/josh)
255
+ * José Valim [josevalim](https://github.com/josevalim)
256
+ * Michael Fellinger [manveru](https://github.com/manveru)
257
+ * Santiago Pastorino [spastorino](https://github.com/spastorino)
258
+ * Konstantin Haase [rkh](https://github.com/rkh)
259
+
260
+ would like to thank:
261
+
262
+ * Adrian Madrid, for the LiteSpeed handler.
263
+ * Christoffer Sawicki, for the first Rails adapter and `Rack::Deflater`.
264
+ * Tim Fletcher, for the HTTP authentication code.
265
+ * Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
266
+ * Armin Ronacher, for the logo and racktools.
267
+ * Alex Beregszaszi, Alexander Kahn, Anil Wadghule, Aredridel, Ben Alpert, Dan
268
+ Kubb, Daniel Roethlisberger, Matt Todd, Tom Robinson, Phil Hagelberg, S. Brent
269
+ Faulkner, Bosko Milekic, Daniel Rodríguez Troitiño, Genki Takiuchi, Geoffrey
270
+ Grosenbach, Julien Sanchez, Kamal Fariz Mahyuddin, Masayoshi Takahashi,
271
+ Patrick Aljordm, Mig, Kazuhiro Nishiyama, Jon Bardin, Konstantin Haase, Larry
272
+ Siden, Matias Korhonen, Sam Ruby, Simon Chiang, Tim Connor, Timur Batyrshin,
273
+ and Zach Brock for bug fixing and other improvements.
274
+ * Eric Wong, Hongli Lai, Jeremy Kemper for their continuous support and API
275
+ improvements.
276
+ * Yehuda Katz and Carl Lerche for refactoring rackup.
277
+ * Brian Candler, for `Rack::ContentType`.
278
+ * Graham Batty, for improved handler loading.
279
+ * Stephen Bannasch, for bug reports and documentation.
280
+ * Gary Wright, for proposing a better `Rack::Response` interface.
281
+ * Jonathan Buch, for improvements regarding `Rack::Response`.
282
+ * Armin Röhrl, for tracking down bugs in the Cookie generator.
283
+ * Alexander Kellett for testing the Gem and reviewing the announcement.
284
+ * Marcus Rückert, for help with configuring and debugging lighttpd.
285
+ * The WSGI team for the well-done and documented work they've done and Rack
286
+ builds up on.
287
+ * All bug reporters and patch contributors not mentioned above.
288
+
289
+ ## License
290
+
291
+ Rack is released under the [MIT License](MIT-LICENSE).
292
+
293
+ [Rack Specification]: SPEC.rdoc