rack 1.0.1 → 2.2.21
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 +7 -0
- data/CHANGELOG.md +829 -0
- data/CONTRIBUTING.md +136 -0
- data/{COPYING → MIT-LICENSE} +4 -2
- data/README.rdoc +355 -0
- data/Rakefile +64 -98
- data/SPEC.rdoc +292 -0
- data/bin/rackup +3 -174
- data/contrib/rack.png +0 -0
- data/contrib/rack.svg +150 -0
- data/contrib/rack_logo.svg +164 -111
- data/contrib/rdoc.css +412 -0
- data/example/lobster.ru +2 -0
- data/example/protectedlobster.rb +4 -2
- data/example/protectedlobster.ru +3 -1
- data/lib/rack/auth/abstract/handler.rb +7 -5
- data/lib/rack/auth/abstract/request.rb +12 -2
- data/lib/rack/auth/basic.rb +6 -4
- data/lib/rack/auth/digest/md5.rb +20 -13
- data/lib/rack/auth/digest/nonce.rb +6 -4
- data/lib/rack/auth/digest/params.rb +11 -12
- data/lib/rack/auth/digest/request.rb +15 -12
- data/lib/rack/body_proxy.rb +45 -0
- data/lib/rack/builder.rb +213 -19
- data/lib/rack/cascade.rb +50 -18
- data/lib/rack/chunked.rb +95 -27
- data/lib/rack/common_logger.rb +84 -0
- data/lib/rack/conditional_get.rb +83 -0
- data/lib/rack/config.rb +22 -0
- data/lib/rack/content_length.rb +19 -10
- data/lib/rack/content_type.rb +12 -5
- data/lib/rack/core_ext/regexp.rb +14 -0
- data/lib/rack/deflater.rb +90 -42
- data/lib/rack/directory.rb +118 -72
- data/lib/rack/etag.rb +77 -0
- data/lib/rack/events.rb +153 -0
- data/lib/rack/file.rb +4 -85
- data/lib/rack/files.rb +218 -0
- data/lib/rack/handler/cgi.rb +22 -24
- data/lib/rack/handler/fastcgi.rb +34 -24
- data/lib/rack/handler/lsws.rb +16 -15
- data/lib/rack/handler/scgi.rb +38 -29
- data/lib/rack/handler/thin.rb +23 -7
- data/lib/rack/handler/webrick.rb +95 -37
- data/lib/rack/handler.rb +49 -14
- data/lib/rack/head.rb +19 -13
- data/lib/rack/lint.rb +466 -217
- data/lib/rack/lobster.rb +19 -14
- data/lib/rack/lock.rb +24 -8
- data/lib/rack/logger.rb +20 -0
- data/lib/rack/media_type.rb +53 -0
- data/lib/rack/method_override.rb +52 -0
- data/lib/rack/mime.rb +652 -171
- data/lib/rack/mock.rb +203 -64
- data/lib/rack/multipart/generator.rb +97 -0
- data/lib/rack/multipart/parser.rb +440 -0
- data/lib/rack/multipart/uploaded_file.rb +41 -0
- data/lib/rack/multipart.rb +64 -0
- data/lib/rack/null_logger.rb +39 -0
- data/lib/rack/query_parser.rb +266 -0
- data/lib/rack/recursive.rb +18 -11
- data/lib/rack/reloader.rb +13 -5
- data/lib/rack/request.rb +607 -191
- data/lib/rack/response.rb +245 -110
- data/lib/rack/rewindable_input.rb +15 -21
- data/lib/rack/runtime.rb +34 -0
- data/lib/rack/sendfile.rb +192 -0
- data/lib/rack/server.rb +466 -0
- data/lib/rack/session/abstract/id.rb +449 -68
- data/lib/rack/session/cookie.rb +159 -47
- data/lib/rack/session/memcache.rb +4 -103
- data/lib/rack/session/pool.rb +39 -49
- data/lib/rack/show_exceptions.rb +390 -0
- data/lib/rack/{showstatus.rb → show_status.rb} +21 -14
- data/lib/rack/static.rb +164 -14
- data/lib/rack/tempfile_reaper.rb +22 -0
- data/lib/rack/urlmap.rb +60 -18
- data/lib/rack/utils.rb +508 -277
- data/lib/rack/version.rb +29 -0
- data/lib/rack.rb +85 -34
- data/rack.gemspec +43 -51
- metadata +119 -207
- data/KNOWN-ISSUES +0 -18
- data/RDOX +0 -428
- data/README +0 -364
- data/SPEC +0 -164
- data/lib/rack/adapter/camping.rb +0 -22
- data/lib/rack/auth/openid.rb +0 -480
- data/lib/rack/commonlogger.rb +0 -61
- data/lib/rack/conditionalget.rb +0 -47
- data/lib/rack/handler/evented_mongrel.rb +0 -8
- data/lib/rack/handler/mongrel.rb +0 -87
- data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
- data/lib/rack/methodoverride.rb +0 -27
- data/lib/rack/showexceptions.rb +0 -349
- data/test/cgi/lighttpd.conf +0 -20
- data/test/cgi/test +0 -9
- data/test/cgi/test.fcgi +0 -8
- data/test/cgi/test.ru +0 -7
- data/test/multipart/binary +0 -0
- data/test/multipart/empty +0 -10
- data/test/multipart/ie +0 -6
- data/test/multipart/nested +0 -10
- data/test/multipart/none +0 -9
- data/test/multipart/semicolon +0 -6
- data/test/multipart/text +0 -10
- data/test/spec_rack_auth_basic.rb +0 -73
- data/test/spec_rack_auth_digest.rb +0 -226
- data/test/spec_rack_auth_openid.rb +0 -84
- data/test/spec_rack_builder.rb +0 -84
- data/test/spec_rack_camping.rb +0 -51
- data/test/spec_rack_cascade.rb +0 -50
- data/test/spec_rack_cgi.rb +0 -89
- data/test/spec_rack_chunked.rb +0 -62
- data/test/spec_rack_commonlogger.rb +0 -32
- data/test/spec_rack_conditionalget.rb +0 -41
- data/test/spec_rack_content_length.rb +0 -43
- data/test/spec_rack_content_type.rb +0 -30
- data/test/spec_rack_deflater.rb +0 -127
- data/test/spec_rack_directory.rb +0 -61
- data/test/spec_rack_fastcgi.rb +0 -89
- data/test/spec_rack_file.rb +0 -75
- data/test/spec_rack_handler.rb +0 -43
- data/test/spec_rack_head.rb +0 -30
- data/test/spec_rack_lint.rb +0 -521
- data/test/spec_rack_lobster.rb +0 -45
- data/test/spec_rack_lock.rb +0 -38
- data/test/spec_rack_methodoverride.rb +0 -60
- data/test/spec_rack_mock.rb +0 -157
- data/test/spec_rack_mongrel.rb +0 -189
- data/test/spec_rack_recursive.rb +0 -77
- data/test/spec_rack_request.rb +0 -504
- data/test/spec_rack_response.rb +0 -218
- data/test/spec_rack_rewindable_input.rb +0 -118
- data/test/spec_rack_session_cookie.rb +0 -82
- data/test/spec_rack_session_memcache.rb +0 -240
- data/test/spec_rack_session_pool.rb +0 -172
- data/test/spec_rack_showexceptions.rb +0 -21
- data/test/spec_rack_showstatus.rb +0 -72
- data/test/spec_rack_static.rb +0 -37
- data/test/spec_rack_thin.rb +0 -91
- data/test/spec_rack_urlmap.rb +0 -185
- data/test/spec_rack_utils.rb +0 -387
- data/test/spec_rack_webrick.rb +0 -130
- data/test/testrequest.rb +0 -57
- data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
- data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Contributing to Rack
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
Rack is work of [hundreds of contributors](https://github.com/rack/rack/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/rack/rack/pulls), [propose features and discuss issues](https://github.com/rack/rack/issues). When in doubt, post to the [rack-devel](http://groups.google.com/group/rack-devel) mailing list.
|
|
5
|
+
|
|
6
|
+
#### Fork the Project
|
|
7
|
+
|
|
8
|
+
Fork the [project on Github](https://github.com/rack/rack) and check out your copy.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
git clone https://github.com/contributor/rack.git
|
|
12
|
+
cd rack
|
|
13
|
+
git remote add upstream https://github.com/rack/rack.git
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
#### Create a Topic Branch
|
|
17
|
+
|
|
18
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
git checkout master
|
|
22
|
+
git pull upstream master
|
|
23
|
+
git checkout -b my-feature-branch
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Bundle Install and Quick Test
|
|
27
|
+
|
|
28
|
+
Ensure that you can build the project and run quick tests.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
bundle install --without extra
|
|
32
|
+
bundle exec rake test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Running All Tests
|
|
36
|
+
|
|
37
|
+
Install all dependencies.
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
bundle install
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Run all tests.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
rake test
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The test suite has no dependencies outside of the core Ruby installation and bacon.
|
|
50
|
+
|
|
51
|
+
Some tests will be skipped if a dependency is not found.
|
|
52
|
+
|
|
53
|
+
To run the test suite completely, you need:
|
|
54
|
+
|
|
55
|
+
* fcgi
|
|
56
|
+
* dalli
|
|
57
|
+
* thin
|
|
58
|
+
|
|
59
|
+
To test Memcache sessions, you need memcached (will be run on port 11211) and dalli installed.
|
|
60
|
+
|
|
61
|
+
#### Write Tests
|
|
62
|
+
|
|
63
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
|
|
64
|
+
|
|
65
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
|
66
|
+
|
|
67
|
+
#### Write Code
|
|
68
|
+
|
|
69
|
+
Implement your feature or bug fix.
|
|
70
|
+
|
|
71
|
+
Make sure that `bundle exec rake fulltest` completes without errors.
|
|
72
|
+
|
|
73
|
+
#### Write Documentation
|
|
74
|
+
|
|
75
|
+
Document any external behavior in the [README](README.rdoc).
|
|
76
|
+
|
|
77
|
+
#### Update Changelog
|
|
78
|
+
|
|
79
|
+
Add a line to [CHANGELOG](CHANGELOG.md).
|
|
80
|
+
|
|
81
|
+
#### Commit Changes
|
|
82
|
+
|
|
83
|
+
Make sure git knows your name and email address:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
git config --global user.name "Your Name"
|
|
87
|
+
git config --global user.email "contributor@example.com"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
git add ...
|
|
94
|
+
git commit
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Push
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
git push origin my-feature-branch
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Make a Pull Request
|
|
104
|
+
|
|
105
|
+
Go to https://github.com/contributor/rack and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
|
106
|
+
|
|
107
|
+
#### Rebase
|
|
108
|
+
|
|
109
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
git fetch upstream
|
|
113
|
+
git rebase upstream/master
|
|
114
|
+
git push origin my-feature-branch -f
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Make Required Changes
|
|
118
|
+
|
|
119
|
+
Amend your previous commit and force push the changes.
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
git commit --amend
|
|
123
|
+
git push origin my-feature-branch -f
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Check on Your Pull Request
|
|
127
|
+
|
|
128
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
|
129
|
+
|
|
130
|
+
#### Be Patient
|
|
131
|
+
|
|
132
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
|
133
|
+
|
|
134
|
+
#### Thank You
|
|
135
|
+
|
|
136
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/{COPYING → MIT-LICENSE}
RENAMED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2007-2019 Leah Neukirchen <http://leahneukirchen.org/infopage.html>
|
|
2
4
|
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
of this software and associated documentation files (the "Software"), to
|
|
@@ -13,6 +15,6 @@ all copies or substantial portions of the Software.
|
|
|
13
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
16
|
-
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
19
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
20
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
= \Rack, a modular Ruby webserver interface
|
|
2
|
+
|
|
3
|
+
{<img src="https://rack.github.io/logo.png" width="400" alt="rack powers web applications" />}[https://rack.github.io/]
|
|
4
|
+
|
|
5
|
+
{<img src="https://circleci.com/gh/rack/rack.svg?style=svg" alt="CircleCI" />}[https://circleci.com/gh/rack/rack]
|
|
6
|
+
{<img src="https://badge.fury.io/rb/rack.svg" alt="Gem Version" />}[http://badge.fury.io/rb/rack]
|
|
7
|
+
{<img src="https://api.dependabot.com/badges/compatibility_score?dependency-name=rack&package-manager=bundler&version-scheme=semver" alt="SemVer Stability" />}[https://dependabot.com/compatibility-score.html?dependency-name=rack&package-manager=bundler&version-scheme=semver]
|
|
8
|
+
{<img src="http://inch-ci.org/github/rack/rack.svg?branch=master" alt="Inline docs" />}[http://inch-ci.org/github/rack/rack]
|
|
9
|
+
|
|
10
|
+
\Rack provides a minimal, modular, and adaptable interface for developing
|
|
11
|
+
web applications in Ruby. By wrapping HTTP requests and responses in
|
|
12
|
+
the simplest way possible, it unifies and distills the API for web
|
|
13
|
+
servers, web frameworks, and software in between (the so-called
|
|
14
|
+
middleware) into a single method call.
|
|
15
|
+
|
|
16
|
+
The exact details of this are described in the \Rack specification,
|
|
17
|
+
which all \Rack applications should conform to.
|
|
18
|
+
|
|
19
|
+
== Supported web servers
|
|
20
|
+
|
|
21
|
+
The included *handlers* connect all kinds of web servers to \Rack:
|
|
22
|
+
|
|
23
|
+
* WEBrick[https://github.com/ruby/webrick]
|
|
24
|
+
* FCGI
|
|
25
|
+
* CGI
|
|
26
|
+
* SCGI
|
|
27
|
+
* LiteSpeed[https://www.litespeedtech.com/]
|
|
28
|
+
* Thin[https://rubygems.org/gems/thin]
|
|
29
|
+
|
|
30
|
+
These web servers include \Rack handlers in their distributions:
|
|
31
|
+
|
|
32
|
+
* Agoo[https://github.com/ohler55/agoo]
|
|
33
|
+
* Falcon[https://github.com/socketry/falcon]
|
|
34
|
+
* Iodine[https://github.com/boazsegev/iodine]
|
|
35
|
+
* {NGINX Unit}[https://unit.nginx.org/]
|
|
36
|
+
* {Phusion Passenger}[https://www.phusionpassenger.com/] (which is mod_rack for Apache and for nginx)
|
|
37
|
+
* Puma[https://puma.io/]
|
|
38
|
+
* Unicorn[https://yhbt.net/unicorn/]
|
|
39
|
+
* uWSGI[https://uwsgi-docs.readthedocs.io/en/latest/]
|
|
40
|
+
|
|
41
|
+
Any valid \Rack app will run the same on all these handlers, without
|
|
42
|
+
changing anything.
|
|
43
|
+
|
|
44
|
+
== Supported web frameworks
|
|
45
|
+
|
|
46
|
+
These frameworks and many others support the \Rack API:
|
|
47
|
+
|
|
48
|
+
* Camping[http://www.ruby-camping.com/]
|
|
49
|
+
* Coset[http://leahneukirchen.org/repos/coset/]
|
|
50
|
+
* Hanami[https://hanamirb.org/]
|
|
51
|
+
* Padrino[http://padrinorb.com/]
|
|
52
|
+
* Ramaze[http://ramaze.net/]
|
|
53
|
+
* Roda[https://github.com/jeremyevans/roda]
|
|
54
|
+
* {Ruby on Rails}[https://rubyonrails.org/]
|
|
55
|
+
* Rum[https://github.com/leahneukirchen/rum]
|
|
56
|
+
* Sinatra[http://sinatrarb.com/]
|
|
57
|
+
* Utopia[https://github.com/socketry/utopia]
|
|
58
|
+
* WABuR[https://github.com/ohler55/wabur]
|
|
59
|
+
|
|
60
|
+
== Available middleware shipped with \Rack
|
|
61
|
+
|
|
62
|
+
Between the server and the framework, \Rack can be customized to your
|
|
63
|
+
applications needs using middleware. \Rack itself ships with the following
|
|
64
|
+
middleware:
|
|
65
|
+
|
|
66
|
+
* Rack::Chunked, for streaming responses using chunked encoding.
|
|
67
|
+
* Rack::CommonLogger, for creating Apache-style logfiles.
|
|
68
|
+
* Rack::ConditionalGet, for returning not modified responses when the response
|
|
69
|
+
has not changed.
|
|
70
|
+
* Rack::Config, for modifying the environment before processing the request.
|
|
71
|
+
* Rack::ContentLength, for setting Content-Length header based on body size.
|
|
72
|
+
* Rack::ContentType, for setting default Content-Type header for responses.
|
|
73
|
+
* Rack::Deflater, for compressing responses with gzip.
|
|
74
|
+
* Rack::ETag, for setting ETag header on string bodies.
|
|
75
|
+
* Rack::Events, for providing easy hooks when a request is received
|
|
76
|
+
and when the response is sent.
|
|
77
|
+
* Rack::Files, for serving static files.
|
|
78
|
+
* Rack::Head, for returning an empty body for HEAD requests.
|
|
79
|
+
* Rack::Lint, for checking conformance to the \Rack API.
|
|
80
|
+
* Rack::Lock, for serializing requests using a mutex.
|
|
81
|
+
* Rack::Logger, for setting a logger to handle logging errors.
|
|
82
|
+
* Rack::MethodOverride, for modifying the request method based on a submitted
|
|
83
|
+
parameter.
|
|
84
|
+
* Rack::Recursive, for including data from other paths in the application,
|
|
85
|
+
and for performing internal redirects.
|
|
86
|
+
* Rack::Reloader, for reloading files if they have been modified.
|
|
87
|
+
* Rack::Runtime, for including a response header with the time taken to
|
|
88
|
+
process the request.
|
|
89
|
+
* Rack::Sendfile, for working with web servers that can use optimized
|
|
90
|
+
file serving for file system paths.
|
|
91
|
+
* Rack::ShowException, for catching unhandled exceptions and
|
|
92
|
+
presenting them in a nice and helpful way with clickable backtrace.
|
|
93
|
+
* Rack::ShowStatus, for using nice error pages for empty client error
|
|
94
|
+
responses.
|
|
95
|
+
* Rack::Static, for more configurable serving of static files.
|
|
96
|
+
* Rack::TempfileReaper, for removing temporary files creating during a
|
|
97
|
+
request.
|
|
98
|
+
|
|
99
|
+
All these components use the same interface, which is described in
|
|
100
|
+
detail in the \Rack specification. These optional components can be
|
|
101
|
+
used in any way you wish.
|
|
102
|
+
|
|
103
|
+
== Convenience
|
|
104
|
+
|
|
105
|
+
If you want to develop outside of existing frameworks, implement your
|
|
106
|
+
own ones, or develop middleware, \Rack provides many helpers to create
|
|
107
|
+
\Rack applications quickly and without doing the same web stuff all
|
|
108
|
+
over:
|
|
109
|
+
|
|
110
|
+
* Rack::Request, which also provides query string parsing and
|
|
111
|
+
multipart handling.
|
|
112
|
+
* Rack::Response, for convenient generation of HTTP replies and
|
|
113
|
+
cookie handling.
|
|
114
|
+
* Rack::MockRequest and Rack::MockResponse for efficient and quick
|
|
115
|
+
testing of \Rack application without real HTTP round-trips.
|
|
116
|
+
* Rack::Cascade, for trying additional \Rack applications if an
|
|
117
|
+
application returns a not found or method not supported response.
|
|
118
|
+
* Rack::Directory, for serving files under a given directory, with
|
|
119
|
+
directory indexes.
|
|
120
|
+
* Rack::MediaType, for parsing Content-Type headers.
|
|
121
|
+
* Rack::Mime, for determining Content-Type based on file extension.
|
|
122
|
+
* Rack::RewindableInput, for making any IO object rewindable, using
|
|
123
|
+
a temporary file buffer.
|
|
124
|
+
* Rack::URLMap, to route to multiple applications inside the same process.
|
|
125
|
+
|
|
126
|
+
== rack-contrib
|
|
127
|
+
|
|
128
|
+
The plethora of useful middleware created the need for a project that
|
|
129
|
+
collects fresh \Rack middleware. rack-contrib includes a variety of
|
|
130
|
+
add-on components for \Rack and it is easy to contribute new modules.
|
|
131
|
+
|
|
132
|
+
* https://github.com/rack/rack-contrib
|
|
133
|
+
|
|
134
|
+
== rackup
|
|
135
|
+
|
|
136
|
+
rackup is a useful tool for running \Rack applications, which uses the
|
|
137
|
+
Rack::Builder DSL to configure middleware and build up applications
|
|
138
|
+
easily.
|
|
139
|
+
|
|
140
|
+
rackup automatically figures out the environment it is run in, and
|
|
141
|
+
runs your application as FastCGI, CGI, or WEBrick---all from the
|
|
142
|
+
same configuration.
|
|
143
|
+
|
|
144
|
+
== Quick start
|
|
145
|
+
|
|
146
|
+
Try the lobster!
|
|
147
|
+
|
|
148
|
+
Either with the embedded WEBrick starter:
|
|
149
|
+
|
|
150
|
+
ruby -Ilib lib/rack/lobster.rb
|
|
151
|
+
|
|
152
|
+
Or with rackup:
|
|
153
|
+
|
|
154
|
+
bin/rackup -Ilib example/lobster.ru
|
|
155
|
+
|
|
156
|
+
By default, the lobster is found at http://localhost:9292.
|
|
157
|
+
|
|
158
|
+
== Installing with RubyGems
|
|
159
|
+
|
|
160
|
+
A Gem of \Rack is available at {rubygems.org}[https://rubygems.org/gems/rack]. You can install it with:
|
|
161
|
+
|
|
162
|
+
gem install rack
|
|
163
|
+
|
|
164
|
+
== Usage
|
|
165
|
+
|
|
166
|
+
You should require the library:
|
|
167
|
+
|
|
168
|
+
require 'rack'
|
|
169
|
+
|
|
170
|
+
\Rack uses autoload to automatically load other files \Rack ships with on demand,
|
|
171
|
+
so you should not need require paths under +rack+. If you require paths under
|
|
172
|
+
+rack+ without requiring +rack+ itself, things may not work correctly.
|
|
173
|
+
|
|
174
|
+
== Configuration
|
|
175
|
+
|
|
176
|
+
Several parameters can be modified on Rack::Utils to configure \Rack behaviour.
|
|
177
|
+
|
|
178
|
+
e.g:
|
|
179
|
+
|
|
180
|
+
Rack::Utils.key_space_limit = 128
|
|
181
|
+
|
|
182
|
+
=== `RACK_QUERY_PARSER_BYTESIZE_LIMIT`
|
|
183
|
+
|
|
184
|
+
This environment variable sets the default for the maximum query string bytesize
|
|
185
|
+
that `Rack::QueryParser` will attempt to parse. Attempts to use a query string
|
|
186
|
+
that exceeds this number of bytes will result in a
|
|
187
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
|
188
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
|
189
|
+
|
|
190
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
|
191
|
+
the `bytesize_limit` keyword argument when creating the `Rack::QueryParser`.
|
|
192
|
+
|
|
193
|
+
=== `RACK_QUERY_PARSER_PARAMS_LIMIT`
|
|
194
|
+
|
|
195
|
+
This environment variable sets the default for the maximum number of query
|
|
196
|
+
parameters that `Rack::QueryParser` will attempt to parse. Attempts to use a
|
|
197
|
+
query string with more than this many query parameters will result in a
|
|
198
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
|
199
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
|
200
|
+
|
|
201
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
|
202
|
+
the `params_limit` keyword argument when creating the `Rack::QueryParser`.
|
|
203
|
+
|
|
204
|
+
This is implemented by counting the number of parameter separators in the
|
|
205
|
+
query string, before attempting parsing, so if the same parameter key is
|
|
206
|
+
used multiple times in the query, each counts as a separate parameter for
|
|
207
|
+
this check.
|
|
208
|
+
|
|
209
|
+
=== `RACK_MULTIPART_BUFFERED_UPLOAD_BYTESIZE_LIMIT`
|
|
210
|
+
|
|
211
|
+
This environment variable sets the maximum amount of memory Rack will use
|
|
212
|
+
to buffer multipart parameters when parsing a request body. This considers
|
|
213
|
+
the size of the multipart mime headers and the body part for multipart
|
|
214
|
+
parameters that are buffered in memory and do not use tempfiles. This
|
|
215
|
+
defaults to 16MB if not provided.
|
|
216
|
+
|
|
217
|
+
=== key_space_limit
|
|
218
|
+
|
|
219
|
+
The default number of bytes to allow all parameters keys in a given parameter hash to take up.
|
|
220
|
+
Does not affect nested parameter hashes, so doesn't actually prevent an attacker from using
|
|
221
|
+
more than this many bytes for parameter keys.
|
|
222
|
+
|
|
223
|
+
Defaults to 65536 characters.
|
|
224
|
+
|
|
225
|
+
=== param_depth_limit
|
|
226
|
+
|
|
227
|
+
The maximum amount of nesting allowed in parameters.
|
|
228
|
+
For example, if set to 3, this query string would be allowed:
|
|
229
|
+
|
|
230
|
+
?a[b][c]=d
|
|
231
|
+
|
|
232
|
+
but this query string would not be allowed:
|
|
233
|
+
|
|
234
|
+
?a[b][c][d]=e
|
|
235
|
+
|
|
236
|
+
Limiting the depth prevents a possible stack overflow when parsing parameters.
|
|
237
|
+
|
|
238
|
+
Defaults to 100.
|
|
239
|
+
|
|
240
|
+
=== multipart_file_limit
|
|
241
|
+
|
|
242
|
+
The maximum number of parts with a filename a request can contain.
|
|
243
|
+
Accepting too many part can lead to the server running out of file handles.
|
|
244
|
+
|
|
245
|
+
The default is 128, which means that a single request can't upload more than 128 files at once.
|
|
246
|
+
|
|
247
|
+
Set to 0 for no limit.
|
|
248
|
+
|
|
249
|
+
Can also be set via the +RACK_MULTIPART_FILE_LIMIT+ environment variable.
|
|
250
|
+
|
|
251
|
+
(This is also aliased as +multipart_part_limit+ and +RACK_MULTIPART_PART_LIMIT+ for compatibility)
|
|
252
|
+
|
|
253
|
+
=== multipart_total_part_limit
|
|
254
|
+
|
|
255
|
+
The maximum total number of parts a request can contain of any type, including
|
|
256
|
+
both file and non-file form fields.
|
|
257
|
+
|
|
258
|
+
The default is 4096, which means that a single request can't contain more than
|
|
259
|
+
4096 parts.
|
|
260
|
+
|
|
261
|
+
Set to 0 for no limit.
|
|
262
|
+
|
|
263
|
+
Can also be set via the +RACK_MULTIPART_TOTAL_PART_LIMIT+ environment variable.
|
|
264
|
+
|
|
265
|
+
== Changelog
|
|
266
|
+
|
|
267
|
+
See {CHANGELOG.md}[https://github.com/rack/rack/blob/master/CHANGELOG.md].
|
|
268
|
+
|
|
269
|
+
== Contributing
|
|
270
|
+
|
|
271
|
+
See {CONTRIBUTING.md}[https://github.com/rack/rack/blob/master/CONTRIBUTING.md].
|
|
272
|
+
|
|
273
|
+
== Contact
|
|
274
|
+
|
|
275
|
+
Please post bugs, suggestions and patches to
|
|
276
|
+
the bug tracker at {issues}[https://github.com/rack/rack/issues].
|
|
277
|
+
|
|
278
|
+
Please post security related bugs and suggestions to the core team at
|
|
279
|
+
<https://groups.google.com/forum/#!forum/rack-core> or rack-core@googlegroups.com. This
|
|
280
|
+
list is not public. Due to wide usage of the library, it is strongly preferred
|
|
281
|
+
that we manage timing in order to provide viable patches at the time of
|
|
282
|
+
disclosure. Your assistance in this matter is greatly appreciated.
|
|
283
|
+
|
|
284
|
+
Mailing list archives are available at
|
|
285
|
+
<https://groups.google.com/forum/#!forum/rack-devel>.
|
|
286
|
+
|
|
287
|
+
Git repository (send Git patches to the mailing list):
|
|
288
|
+
|
|
289
|
+
* https://github.com/rack/rack
|
|
290
|
+
|
|
291
|
+
You are also welcome to join the #rack channel on irc.freenode.net.
|
|
292
|
+
|
|
293
|
+
== Thanks
|
|
294
|
+
|
|
295
|
+
The \Rack Core Team, consisting of
|
|
296
|
+
|
|
297
|
+
* Aaron Patterson (tenderlove[https://github.com/tenderlove])
|
|
298
|
+
* Samuel Williams (ioquatix[https://github.com/ioquatix])
|
|
299
|
+
* Jeremy Evans (jeremyevans[https://github.com/jeremyevans])
|
|
300
|
+
* Eileen Uchitelle (eileencodes[https://github.com/eileencodes])
|
|
301
|
+
* Matthew Draper (matthewd[https://github.com/matthewd])
|
|
302
|
+
* Rafael França (rafaelfranca[https://github.com/rafaelfranca])
|
|
303
|
+
|
|
304
|
+
and the \Rack Alumni
|
|
305
|
+
|
|
306
|
+
* Ryan Tomayko (rtomayko[https://github.com/rtomayko])
|
|
307
|
+
* Scytrin dai Kinthra (scytrin[https://github.com/scytrin])
|
|
308
|
+
* Leah Neukirchen (leahneukirchen[https://github.com/leahneukirchen])
|
|
309
|
+
* James Tucker (raggi[https://github.com/raggi])
|
|
310
|
+
* Josh Peek (josh[https://github.com/josh])
|
|
311
|
+
* José Valim (josevalim[https://github.com/josevalim])
|
|
312
|
+
* Michael Fellinger (manveru[https://github.com/manveru])
|
|
313
|
+
* Santiago Pastorino (spastorino[https://github.com/spastorino])
|
|
314
|
+
* Konstantin Haase (rkh[https://github.com/rkh])
|
|
315
|
+
|
|
316
|
+
would like to thank:
|
|
317
|
+
|
|
318
|
+
* Adrian Madrid, for the LiteSpeed handler.
|
|
319
|
+
* Christoffer Sawicki, for the first Rails adapter and Rack::Deflater.
|
|
320
|
+
* Tim Fletcher, for the HTTP authentication code.
|
|
321
|
+
* Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
|
|
322
|
+
* Armin Ronacher, for the logo and racktools.
|
|
323
|
+
* Alex Beregszaszi, Alexander Kahn, Anil Wadghule, Aredridel, Ben
|
|
324
|
+
Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd, Tom Robinson,
|
|
325
|
+
Phil Hagelberg, S. Brent Faulkner, Bosko Milekic, Daniel Rodríguez
|
|
326
|
+
Troitiño, Genki Takiuchi, Geoffrey Grosenbach, Julien Sanchez, Kamal
|
|
327
|
+
Fariz Mahyuddin, Masayoshi Takahashi, Patrick Aljordm, Mig, Kazuhiro
|
|
328
|
+
Nishiyama, Jon Bardin, Konstantin Haase, Larry Siden, Matias
|
|
329
|
+
Korhonen, Sam Ruby, Simon Chiang, Tim Connor, Timur Batyrshin, and
|
|
330
|
+
Zach Brock for bug fixing and other improvements.
|
|
331
|
+
* Eric Wong, Hongli Lai, Jeremy Kemper for their continuous support
|
|
332
|
+
and API improvements.
|
|
333
|
+
* Yehuda Katz and Carl Lerche for refactoring rackup.
|
|
334
|
+
* Brian Candler, for Rack::ContentType.
|
|
335
|
+
* Graham Batty, for improved handler loading.
|
|
336
|
+
* Stephen Bannasch, for bug reports and documentation.
|
|
337
|
+
* Gary Wright, for proposing a better Rack::Response interface.
|
|
338
|
+
* Jonathan Buch, for improvements regarding Rack::Response.
|
|
339
|
+
* Armin Röhrl, for tracking down bugs in the Cookie generator.
|
|
340
|
+
* Alexander Kellett for testing the Gem and reviewing the announcement.
|
|
341
|
+
* Marcus Rückert, for help with configuring and debugging lighttpd.
|
|
342
|
+
* The WSGI team for the well-done and documented work they've done and
|
|
343
|
+
\Rack builds up on.
|
|
344
|
+
* All bug reporters and patch contributors not mentioned above.
|
|
345
|
+
|
|
346
|
+
== Links
|
|
347
|
+
|
|
348
|
+
\Rack:: <https://rack.github.io/>
|
|
349
|
+
Official \Rack repositories:: <https://github.com/rack>
|
|
350
|
+
\Rack Bug Tracking:: <https://github.com/rack/rack/issues>
|
|
351
|
+
rack-devel mailing list:: <https://groups.google.com/forum/#!forum/rack-devel>
|
|
352
|
+
|
|
353
|
+
== License
|
|
354
|
+
|
|
355
|
+
\Rack is released under the {MIT License}[https://opensource.org/licenses/MIT].
|