rack 2.0.9.4 → 2.1.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.
- checksums.yaml +4 -4
- data/{HISTORY.md → CHANGELOG.md} +214 -164
- data/{COPYING → MIT-LICENSE} +4 -2
- data/README.rdoc +79 -133
- data/Rakefile +25 -18
- data/SPEC +9 -9
- data/bin/rackup +1 -0
- data/example/lobster.ru +2 -0
- data/example/protectedlobster.rb +3 -1
- data/example/protectedlobster.ru +2 -0
- data/lib/rack/auth/abstract/handler.rb +3 -1
- data/lib/rack/auth/abstract/request.rb +2 -0
- data/lib/rack/auth/basic.rb +4 -1
- data/lib/rack/auth/digest/md5.rb +9 -7
- data/lib/rack/auth/digest/nonce.rb +6 -3
- data/lib/rack/auth/digest/params.rb +4 -2
- data/lib/rack/auth/digest/request.rb +2 -0
- data/lib/rack/body_proxy.rb +3 -6
- data/lib/rack/builder.rb +38 -15
- data/lib/rack/cascade.rb +6 -5
- data/lib/rack/chunked.rb +29 -6
- data/lib/rack/common_logger.rb +9 -11
- data/lib/rack/conditional_get.rb +3 -1
- data/lib/rack/config.rb +2 -0
- data/lib/rack/content_length.rb +3 -1
- data/lib/rack/content_type.rb +3 -1
- data/lib/rack/core_ext/regexp.rb +14 -0
- data/lib/rack/deflater.rb +28 -17
- data/lib/rack/directory.rb +17 -14
- data/lib/rack/etag.rb +3 -1
- data/lib/rack/events.rb +5 -3
- data/lib/rack/file.rb +5 -173
- data/lib/rack/files.rb +178 -0
- data/lib/rack/handler/cgi.rb +3 -1
- data/lib/rack/handler/fastcgi.rb +4 -2
- data/lib/rack/handler/lsws.rb +3 -1
- data/lib/rack/handler/scgi.rb +9 -6
- data/lib/rack/handler/thin.rb +3 -1
- data/lib/rack/handler/webrick.rb +4 -2
- data/lib/rack/handler.rb +7 -2
- data/lib/rack/head.rb +2 -0
- data/lib/rack/lint.rb +15 -12
- data/lib/rack/lobster.rb +7 -5
- data/lib/rack/lock.rb +2 -0
- data/lib/rack/logger.rb +2 -0
- data/lib/rack/media_type.rb +10 -5
- data/lib/rack/method_override.rb +4 -2
- data/lib/rack/mime.rb +9 -1
- data/lib/rack/mock.rb +74 -15
- data/lib/rack/multipart/generator.rb +6 -7
- data/lib/rack/multipart/parser.rb +55 -62
- data/lib/rack/multipart/uploaded_file.rb +2 -0
- data/lib/rack/multipart.rb +6 -3
- data/lib/rack/null_logger.rb +2 -0
- data/lib/rack/query_parser.rb +51 -25
- data/lib/rack/recursive.rb +7 -5
- data/lib/rack/reloader.rb +10 -4
- data/lib/rack/request.rb +79 -26
- data/lib/rack/response.rb +71 -31
- data/lib/rack/rewindable_input.rb +4 -2
- data/lib/rack/runtime.rb +4 -2
- data/lib/rack/sendfile.rb +15 -8
- data/lib/rack/server.rb +88 -16
- data/lib/rack/session/abstract/id.rb +40 -22
- data/lib/rack/session/cookie.rb +10 -9
- data/lib/rack/session/memcache.rb +4 -93
- data/lib/rack/session/pool.rb +4 -2
- data/lib/rack/show_exceptions.rb +15 -9
- data/lib/rack/show_status.rb +4 -2
- data/lib/rack/static.rb +15 -10
- data/lib/rack/tempfile_reaper.rb +2 -0
- data/lib/rack/urlmap.rb +11 -2
- data/lib/rack/utils.rb +64 -93
- data/lib/rack.rb +63 -60
- data/rack.gemspec +17 -7
- metadata +33 -175
- data/test/builder/an_underscore_app.rb +0 -5
- data/test/builder/anything.rb +0 -5
- data/test/builder/comment.ru +0 -4
- data/test/builder/end.ru +0 -5
- data/test/builder/line.ru +0 -1
- data/test/builder/options.ru +0 -2
- data/test/cgi/assets/folder/test.js +0 -1
- data/test/cgi/assets/fonts/font.eot +0 -1
- data/test/cgi/assets/images/image.png +0 -1
- data/test/cgi/assets/index.html +0 -1
- data/test/cgi/assets/javascripts/app.js +0 -1
- data/test/cgi/assets/stylesheets/app.css +0 -1
- data/test/cgi/lighttpd.conf +0 -26
- data/test/cgi/rackup_stub.rb +0 -6
- data/test/cgi/sample_rackup.ru +0 -5
- data/test/cgi/test +0 -9
- data/test/cgi/test+directory/test+file +0 -1
- data/test/cgi/test.fcgi +0 -9
- data/test/cgi/test.gz +0 -0
- data/test/cgi/test.ru +0 -5
- data/test/gemloader.rb +0 -10
- data/test/helper.rb +0 -34
- data/test/multipart/bad_robots +0 -259
- data/test/multipart/binary +0 -0
- data/test/multipart/content_type_and_no_filename +0 -6
- data/test/multipart/empty +0 -10
- data/test/multipart/fail_16384_nofile +0 -814
- data/test/multipart/file1.txt +0 -1
- data/test/multipart/filename_and_modification_param +0 -7
- data/test/multipart/filename_and_no_name +0 -6
- data/test/multipart/filename_with_encoded_words +0 -7
- data/test/multipart/filename_with_escaped_quotes +0 -6
- data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
- data/test/multipart/filename_with_null_byte +0 -7
- data/test/multipart/filename_with_percent_escaped_quotes +0 -6
- data/test/multipart/filename_with_single_quote +0 -7
- data/test/multipart/filename_with_unescaped_percentages +0 -6
- data/test/multipart/filename_with_unescaped_percentages2 +0 -6
- data/test/multipart/filename_with_unescaped_percentages3 +0 -6
- data/test/multipart/filename_with_unescaped_quotes +0 -6
- data/test/multipart/ie +0 -6
- data/test/multipart/invalid_character +0 -6
- data/test/multipart/mixed_files +0 -21
- data/test/multipart/nested +0 -10
- data/test/multipart/none +0 -9
- data/test/multipart/quoted +0 -15
- data/test/multipart/rack-logo.png +0 -0
- data/test/multipart/semicolon +0 -6
- data/test/multipart/text +0 -15
- data/test/multipart/three_files_three_fields +0 -31
- data/test/multipart/unity3d_wwwform +0 -11
- data/test/multipart/webkit +0 -32
- data/test/rackup/config.ru +0 -31
- data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
- data/test/spec_auth_basic.rb +0 -89
- data/test/spec_auth_digest.rb +0 -260
- data/test/spec_body_proxy.rb +0 -85
- data/test/spec_builder.rb +0 -233
- data/test/spec_cascade.rb +0 -63
- data/test/spec_cgi.rb +0 -84
- data/test/spec_chunked.rb +0 -103
- data/test/spec_common_logger.rb +0 -107
- data/test/spec_conditional_get.rb +0 -103
- data/test/spec_config.rb +0 -23
- data/test/spec_content_length.rb +0 -86
- data/test/spec_content_type.rb +0 -46
- data/test/spec_deflater.rb +0 -375
- data/test/spec_directory.rb +0 -148
- data/test/spec_etag.rb +0 -108
- data/test/spec_events.rb +0 -133
- data/test/spec_fastcgi.rb +0 -85
- data/test/spec_file.rb +0 -264
- data/test/spec_handler.rb +0 -57
- data/test/spec_head.rb +0 -46
- data/test/spec_lint.rb +0 -520
- data/test/spec_lobster.rb +0 -59
- data/test/spec_lock.rb +0 -204
- data/test/spec_logger.rb +0 -24
- data/test/spec_media_type.rb +0 -42
- data/test/spec_method_override.rb +0 -110
- data/test/spec_mime.rb +0 -51
- data/test/spec_mock.rb +0 -359
- data/test/spec_multipart.rb +0 -721
- data/test/spec_null_logger.rb +0 -21
- data/test/spec_recursive.rb +0 -75
- data/test/spec_request.rb +0 -1423
- data/test/spec_response.rb +0 -528
- data/test/spec_rewindable_input.rb +0 -128
- data/test/spec_runtime.rb +0 -50
- data/test/spec_sendfile.rb +0 -125
- data/test/spec_server.rb +0 -193
- data/test/spec_session_abstract_id.rb +0 -31
- data/test/spec_session_abstract_session_hash.rb +0 -45
- data/test/spec_session_cookie.rb +0 -442
- data/test/spec_session_memcache.rb +0 -357
- data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
- data/test/spec_session_pool.rb +0 -247
- data/test/spec_show_exceptions.rb +0 -93
- data/test/spec_show_status.rb +0 -104
- data/test/spec_static.rb +0 -184
- data/test/spec_tempfile_reaper.rb +0 -64
- data/test/spec_thin.rb +0 -96
- data/test/spec_urlmap.rb +0 -237
- data/test/spec_utils.rb +0 -742
- data/test/spec_version.rb +0 -11
- data/test/spec_webrick.rb +0 -206
- data/test/static/another/index.html +0 -1
- data/test/static/foo.html +0 -1
- data/test/static/index.html +0 -1
- data/test/testrequest.rb +0 -78
- data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
- data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
data/README.rdoc
CHANGED
@@ -1,99 +1,103 @@
|
|
1
|
-
= Rack, a modular Ruby webserver interface
|
1
|
+
= \Rack, a modular Ruby webserver interface
|
2
2
|
|
3
|
-
|
4
|
-
|
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
|
+
|
9
|
+
\Rack provides a minimal, modular, and adaptable interface for developing
|
10
|
+
web applications in Ruby. By wrapping HTTP requests and responses in
|
5
11
|
the simplest way possible, it unifies and distills the API for web
|
6
12
|
servers, web frameworks, and software in between (the so-called
|
7
13
|
middleware) into a single method call.
|
8
14
|
|
9
|
-
The exact details of this are described in the Rack specification,
|
10
|
-
which all Rack applications should conform to.
|
15
|
+
The exact details of this are described in the \Rack specification,
|
16
|
+
which all \Rack applications should conform to.
|
11
17
|
|
12
18
|
== Supported web servers
|
13
19
|
|
14
|
-
The included *handlers* connect all kinds of web servers to Rack:
|
15
|
-
|
20
|
+
The included *handlers* connect all kinds of web servers to \Rack:
|
21
|
+
|
22
|
+
* WEBrick[https://github.com/ruby/webrick]
|
16
23
|
* FCGI
|
17
24
|
* CGI
|
18
25
|
* SCGI
|
19
|
-
* LiteSpeed
|
20
|
-
* Thin
|
21
|
-
|
22
|
-
These web servers include Rack handlers in their distributions:
|
23
|
-
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
* Unicorn
|
30
|
-
*
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
Any valid Rack app will run the same on all these handlers, without
|
26
|
+
* LiteSpeed[https://www.litespeedtech.com/]
|
27
|
+
* Thin[https://rubygems.org/gems/thin]
|
28
|
+
|
29
|
+
These web servers include \Rack handlers in their distributions:
|
30
|
+
|
31
|
+
* Agoo[https://github.com/ohler55/agoo]
|
32
|
+
* Falcon[https://github.com/socketry/falcon]
|
33
|
+
* {NGINX Unit}[https://unit.nginx.org/]
|
34
|
+
* {Phusion Passenger}[https://www.phusionpassenger.com/] (which is mod_rack for Apache and for nginx)
|
35
|
+
* Puma[https://puma.io/]
|
36
|
+
* Unicorn[https://bogomips.org/unicorn/]
|
37
|
+
* uWSGI[https://uwsgi-docs.readthedocs.io/en/latest/]
|
38
|
+
|
39
|
+
Any valid \Rack app will run the same on all these handlers, without
|
35
40
|
changing anything.
|
36
41
|
|
37
42
|
== Supported web frameworks
|
38
43
|
|
39
|
-
These frameworks include Rack adapters in their distributions:
|
40
|
-
|
41
|
-
*
|
42
|
-
*
|
43
|
-
*
|
44
|
-
*
|
45
|
-
* Maveric
|
46
|
-
* Merb
|
44
|
+
These frameworks include \Rack adapters in their distributions:
|
45
|
+
|
46
|
+
* Camping[http://www.ruby-camping.com/]
|
47
|
+
* Coset[http://leahneukirchen.org/repos/coset/]
|
48
|
+
* Hanami[https://hanamirb.org/]
|
49
|
+
* Padrino[http://padrinorb.com/]
|
47
50
|
* Racktools::SimpleApplication
|
48
|
-
* Ramaze
|
49
|
-
*
|
50
|
-
*
|
51
|
-
*
|
52
|
-
*
|
53
|
-
*
|
54
|
-
*
|
55
|
-
* Wee
|
51
|
+
* Ramaze[http://ramaze.net/]
|
52
|
+
* Roda[https://github.com/jeremyevans/roda]
|
53
|
+
* {Ruby on Rails}[https://rubyonrails.org/]
|
54
|
+
* Rum[https://github.com/leahneukirchen/rum]
|
55
|
+
* Sinatra[http://sinatrarb.com/]
|
56
|
+
* Utopia[https://github.com/socketry/utopia]
|
57
|
+
* WABuR[https://github.com/ohler55/wabur]
|
56
58
|
* ... and many others.
|
57
59
|
|
58
60
|
== Available middleware
|
59
61
|
|
60
|
-
Between the server and the framework, Rack can be customized to your
|
62
|
+
Between the server and the framework, \Rack can be customized to your
|
61
63
|
applications needs using middleware, for example:
|
64
|
+
|
62
65
|
* Rack::URLMap, to route to multiple applications inside the same process.
|
63
66
|
* Rack::CommonLogger, for creating Apache-style logfiles.
|
64
67
|
* Rack::ShowException, for catching unhandled exceptions and
|
65
68
|
presenting them in a nice and helpful way with clickable backtrace.
|
66
|
-
* Rack::
|
69
|
+
* Rack::Files, for serving static files.
|
67
70
|
* ...many others!
|
68
71
|
|
69
72
|
All these components use the same interface, which is described in
|
70
|
-
detail in the Rack specification. These optional components can be
|
73
|
+
detail in the \Rack specification. These optional components can be
|
71
74
|
used in any way you wish.
|
72
75
|
|
73
76
|
== Convenience
|
74
77
|
|
75
78
|
If you want to develop outside of existing frameworks, implement your
|
76
|
-
own ones, or develop middleware, Rack provides many helpers to create
|
77
|
-
Rack applications quickly and without doing the same web stuff all
|
79
|
+
own ones, or develop middleware, \Rack provides many helpers to create
|
80
|
+
\Rack applications quickly and without doing the same web stuff all
|
78
81
|
over:
|
82
|
+
|
79
83
|
* Rack::Request, which also provides query string parsing and
|
80
84
|
multipart handling.
|
81
85
|
* Rack::Response, for convenient generation of HTTP replies and
|
82
86
|
cookie handling.
|
83
87
|
* Rack::MockRequest and Rack::MockResponse for efficient and quick
|
84
|
-
testing of Rack application without real HTTP round-trips.
|
88
|
+
testing of \Rack application without real HTTP round-trips.
|
85
89
|
|
86
90
|
== rack-contrib
|
87
91
|
|
88
92
|
The plethora of useful middleware created the need for a project that
|
89
|
-
collects fresh Rack middleware. rack-contrib includes a variety of
|
90
|
-
add-on components for Rack and it is easy to contribute new modules.
|
93
|
+
collects fresh \Rack middleware. rack-contrib includes a variety of
|
94
|
+
add-on components for \Rack and it is easy to contribute new modules.
|
91
95
|
|
92
96
|
* https://github.com/rack/rack-contrib
|
93
97
|
|
94
98
|
== rackup
|
95
99
|
|
96
|
-
rackup is a useful tool for running Rack applications, which uses the
|
100
|
+
rackup is a useful tool for running \Rack applications, which uses the
|
97
101
|
Rack::Builder DSL to configure middleware and build up applications
|
98
102
|
easily.
|
99
103
|
|
@@ -117,18 +121,13 @@ By default, the lobster is found at http://localhost:9292.
|
|
117
121
|
|
118
122
|
== Installing with RubyGems
|
119
123
|
|
120
|
-
A Gem of Rack is available at rubygems.org.
|
124
|
+
A Gem of \Rack is available at {rubygems.org}[https://rubygems.org/gems/rack]. You can install it with:
|
121
125
|
|
122
126
|
gem install rack
|
123
127
|
|
124
|
-
I also provide a local mirror of the gems (and development snapshots)
|
125
|
-
at my site:
|
126
|
-
|
127
|
-
gem install rack --source http://chneukirchen.org/releases/gems/
|
128
|
-
|
129
128
|
== Running the tests
|
130
129
|
|
131
|
-
Testing Rack requires the bacon testing framework:
|
130
|
+
Testing \Rack requires the bacon testing framework:
|
132
131
|
|
133
132
|
bundle install --without extra # to be able to run the fast tests
|
134
133
|
|
@@ -138,7 +137,7 @@ Or:
|
|
138
137
|
|
139
138
|
There is a rake-based test task:
|
140
139
|
|
141
|
-
rake test
|
140
|
+
rake test # tests all the tests
|
142
141
|
|
143
142
|
The testsuite has no dependencies outside of the core Ruby
|
144
143
|
installation and bacon.
|
@@ -146,37 +145,15 @@ installation and bacon.
|
|
146
145
|
To run the test suite completely, you need:
|
147
146
|
|
148
147
|
* fcgi
|
149
|
-
*
|
148
|
+
* dalli
|
150
149
|
* thin
|
151
150
|
|
152
|
-
|
153
|
-
|
154
|
-
libraries and the fcgi gem:
|
155
|
-
|
156
|
-
Download and install lighttpd:
|
157
|
-
|
158
|
-
http://www.lighttpd.net/download
|
159
|
-
|
160
|
-
Installing the FCGI libraries:
|
161
|
-
|
162
|
-
curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
|
163
|
-
tar xzvf fcgi-2.4.0.tar.gz
|
164
|
-
cd fcgi-2.4.0
|
165
|
-
./configure --prefix=/usr/local
|
166
|
-
make
|
167
|
-
sudo make install
|
168
|
-
cd ..
|
169
|
-
|
170
|
-
Installing the Ruby fcgi gem:
|
171
|
-
|
172
|
-
gem install fcgi
|
173
|
-
|
174
|
-
Furthermore, to test Memcache sessions, you need memcached (will be
|
175
|
-
run on port 11211) and memcache-client installed.
|
151
|
+
To test Memcache sessions, you need memcached (will be
|
152
|
+
run on port 11211) and dalli installed.
|
176
153
|
|
177
154
|
== Configuration
|
178
155
|
|
179
|
-
Several parameters can be modified on Rack::Utils to configure Rack behaviour.
|
156
|
+
Several parameters can be modified on Rack::Utils to configure \Rack behaviour.
|
180
157
|
|
181
158
|
e.g:
|
182
159
|
|
@@ -189,50 +166,37 @@ This helps prevent a rogue client from flooding a Request.
|
|
189
166
|
|
190
167
|
Default to 65536 characters (4 kiB in worst case).
|
191
168
|
|
192
|
-
===
|
169
|
+
=== multipart_part_limit
|
193
170
|
|
194
|
-
The maximum number of parts
|
171
|
+
The maximum number of parts a request can contain.
|
195
172
|
Accepting too many part can lead to the server running out of file handles.
|
196
173
|
|
197
174
|
The default is 128, which means that a single request can't upload more than 128 files at once.
|
198
175
|
|
199
176
|
Set to 0 for no limit.
|
200
177
|
|
201
|
-
Can also be set via the +
|
202
|
-
|
203
|
-
(This is also aliased as +multipart_part_limit+ and +RACK_MULTIPART_PART_LIMIT+ for compatibility)
|
204
|
-
|
205
|
-
=== multipart_total_part_limit
|
206
|
-
|
207
|
-
The maximum total number of parts a request can contain of any type, including
|
208
|
-
both file and non-file form fields.
|
209
|
-
|
210
|
-
The default is 4096, which means that a single request can't contain more than
|
211
|
-
4096 parts.
|
212
|
-
|
213
|
-
Set to 0 for no limit.
|
178
|
+
Can also be set via the +RACK_MULTIPART_PART_LIMIT+ environment variable.
|
214
179
|
|
215
|
-
|
180
|
+
== Changelog
|
216
181
|
|
217
|
-
|
218
|
-
|
219
|
-
See <https://github.com/rack/rack/blob/master/HISTORY.md>.
|
182
|
+
See {CHANGELOG.md}[https://github.com/rack/rack/blob/master/CHANGELOG.md].
|
220
183
|
|
221
184
|
== Contact
|
222
185
|
|
223
186
|
Please post bugs, suggestions and patches to
|
224
|
-
the bug tracker at
|
187
|
+
the bug tracker at {issues}[https://github.com/rack/rack/issues].
|
225
188
|
|
226
189
|
Please post security related bugs and suggestions to the core team at
|
227
|
-
<https://groups.google.com/
|
190
|
+
<https://groups.google.com/forum/#!forum/rack-core> or rack-core@googlegroups.com. This
|
228
191
|
list is not public. Due to wide usage of the library, it is strongly preferred
|
229
192
|
that we manage timing in order to provide viable patches at the time of
|
230
193
|
disclosure. Your assistance in this matter is greatly appreciated.
|
231
194
|
|
232
195
|
Mailing list archives are available at
|
233
|
-
<https://groups.google.com/
|
196
|
+
<https://groups.google.com/forum/#!forum/rack-devel>.
|
234
197
|
|
235
198
|
Git repository (send Git patches to the mailing list):
|
199
|
+
|
236
200
|
* https://github.com/rack/rack
|
237
201
|
* http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack-github.git
|
238
202
|
|
@@ -240,9 +204,9 @@ You are also welcome to join the #rack channel on irc.freenode.net.
|
|
240
204
|
|
241
205
|
== Thanks
|
242
206
|
|
243
|
-
The Rack Core Team, consisting of
|
207
|
+
The \Rack Core Team, consisting of
|
244
208
|
|
245
|
-
* Leah Neukirchen (
|
209
|
+
* Leah Neukirchen (leahneukirchen[https://github.com/leahneukirchen])
|
246
210
|
* James Tucker (raggi[https://github.com/raggi])
|
247
211
|
* Josh Peek (josh[https://github.com/josh])
|
248
212
|
* José Valim (josevalim[https://github.com/josevalim])
|
@@ -251,7 +215,7 @@ The Rack Core Team, consisting of
|
|
251
215
|
* Santiago Pastorino (spastorino[https://github.com/spastorino])
|
252
216
|
* Konstantin Haase (rkh[https://github.com/rkh])
|
253
217
|
|
254
|
-
and the Rack Alumnis
|
218
|
+
and the \Rack Alumnis
|
255
219
|
|
256
220
|
* Ryan Tomayko (rtomayko[https://github.com/rtomayko])
|
257
221
|
* Scytrin dai Kinthra (scytrin[https://github.com/scytrin])
|
@@ -283,34 +247,16 @@ would like to thank:
|
|
283
247
|
* Alexander Kellett for testing the Gem and reviewing the announcement.
|
284
248
|
* Marcus Rückert, for help with configuring and debugging lighttpd.
|
285
249
|
* The WSGI team for the well-done and documented work they've done and
|
286
|
-
Rack builds up on.
|
250
|
+
\Rack builds up on.
|
287
251
|
* All bug reporters and patch contributors not mentioned above.
|
288
252
|
|
289
|
-
==
|
290
|
-
|
291
|
-
Copyright (C) 2007, 2008, 2009, 2010 Christian Neukirchen <http://purl.org/net/chneukirchen>
|
292
|
-
|
293
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
294
|
-
of this software and associated documentation files (the "Software"), to
|
295
|
-
deal in the Software without restriction, including without limitation the
|
296
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
297
|
-
sell copies of the Software, and to permit persons to whom the Software is
|
298
|
-
furnished to do so, subject to the following conditions:
|
299
|
-
|
300
|
-
The above copyright notice and this permission notice shall be included in
|
301
|
-
all copies or substantial portions of the Software.
|
253
|
+
== Links
|
302
254
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
308
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
255
|
+
\Rack:: <https://rack.github.io/>
|
256
|
+
Official \Rack repositories:: <https://github.com/rack>
|
257
|
+
\Rack Bug Tracking:: <https://github.com/rack/rack/issues>
|
258
|
+
rack-devel mailing list:: <https://groups.google.com/forum/#!forum/rack-devel>
|
309
259
|
|
310
|
-
==
|
260
|
+
== License
|
311
261
|
|
312
|
-
Rack
|
313
|
-
Official Rack repositories:: <https://github.com/rack>
|
314
|
-
Rack Bug Tracking:: <https://github.com/rack/rack/issues>
|
315
|
-
rack-devel mailing list:: <https://groups.google.com/group/rack-devel>
|
316
|
-
Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
|
262
|
+
\Rack is released under the {MIT License}[https://opensource.org/licenses/MIT].
|
data/Rakefile
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake/testtask"
|
2
4
|
|
3
5
|
desc "Run all the tests"
|
4
|
-
task :
|
6
|
+
task default: :test
|
5
7
|
|
6
8
|
desc "Install gem dependencies"
|
7
9
|
task :deps do
|
@@ -16,7 +18,7 @@ task :deps do
|
|
16
18
|
end
|
17
19
|
|
18
20
|
desc "Make an archive as .tar.gz"
|
19
|
-
task :
|
21
|
+
task dist: %w[chmod changelog spec rdoc] do
|
20
22
|
sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
|
21
23
|
sh "pax -waf #{release}.tar -s ':^:#{release}/:' SPEC ChangeLog doc rack.gemspec"
|
22
24
|
sh "gzip -f -9 #{release}.tar"
|
@@ -31,7 +33,7 @@ task :officialrelease do
|
|
31
33
|
sh "mv stage/#{release}.tar.gz stage/#{release}.gem ."
|
32
34
|
end
|
33
35
|
|
34
|
-
task :
|
36
|
+
task officialrelease_really: %w[spec dist gem] do
|
35
37
|
sh "shasum #{release}.tar.gz #{release}.gem"
|
36
38
|
end
|
37
39
|
|
@@ -46,7 +48,7 @@ task :chmod do
|
|
46
48
|
end
|
47
49
|
|
48
50
|
desc "Generate a ChangeLog"
|
49
|
-
task :
|
51
|
+
task changelog: "ChangeLog"
|
50
52
|
|
51
53
|
file '.git/index'
|
52
54
|
file "ChangeLog" => '.git/index' do
|
@@ -68,8 +70,10 @@ file "ChangeLog" => '.git/index' do
|
|
68
70
|
}
|
69
71
|
end
|
70
72
|
|
71
|
-
file 'lib/rack/lint.rb'
|
72
73
|
desc "Generate Rack Specification"
|
74
|
+
task spec: "SPEC"
|
75
|
+
|
76
|
+
file 'lib/rack/lint.rb'
|
73
77
|
file "SPEC" => 'lib/rack/lint.rb' do
|
74
78
|
File.open("SPEC", "wb") { |file|
|
75
79
|
IO.foreach("lib/rack/lint.rb") { |line|
|
@@ -80,24 +84,27 @@ file "SPEC" => 'lib/rack/lint.rb' do
|
|
80
84
|
}
|
81
85
|
end
|
82
86
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
sh "ruby -I./lib:./test -S minitest #{opts} #{specopts} test/gemloader.rb test/spec*.rb"
|
87
|
+
Rake::TestTask.new("test:regular") do |t|
|
88
|
+
t.libs << "test"
|
89
|
+
t.test_files = FileList["test/**/*_test.rb", "test/**/spec_*.rb", "test/gemloader.rb"]
|
90
|
+
t.warning = false
|
91
|
+
t.verbose = true
|
89
92
|
end
|
90
93
|
|
94
|
+
desc "Run all the fast + platform agnostic tests"
|
95
|
+
task test: %w[spec test:regular]
|
96
|
+
|
91
97
|
desc "Run all the tests we run on CI"
|
92
|
-
task :
|
98
|
+
task ci: :test
|
93
99
|
|
94
|
-
task :
|
100
|
+
task gem: :spec do
|
95
101
|
sh "gem build rack.gemspec"
|
96
102
|
end
|
97
103
|
|
98
|
-
task :
|
104
|
+
task doc: :rdoc
|
105
|
+
|
99
106
|
desc "Generate RDoc documentation"
|
100
|
-
task :
|
107
|
+
task rdoc: %w[changelog spec] do
|
101
108
|
sh(*%w{rdoc --line-numbers --main README.rdoc
|
102
109
|
--title 'Rack\ Documentation' --charset utf-8 -U -o doc} +
|
103
110
|
%w{README.rdoc KNOWN-ISSUES SPEC ChangeLog} +
|
@@ -105,11 +112,11 @@ task :rdoc => %w[ChangeLog SPEC] do
|
|
105
112
|
cp "contrib/rdoc.css", "doc/rdoc.css"
|
106
113
|
end
|
107
114
|
|
108
|
-
task :
|
115
|
+
task pushdoc: :rdoc do
|
109
116
|
sh "rsync -avz doc/ rack.rubyforge.org:/var/www/gforge-projects/rack/doc/"
|
110
117
|
end
|
111
118
|
|
112
|
-
task :
|
119
|
+
task pushsite: :pushdoc do
|
113
120
|
sh "cd site && git gc"
|
114
121
|
sh "rsync -avz site/ rack.rubyforge.org:/var/www/gforge-projects/rack/"
|
115
122
|
sh "cd site && git push"
|
data/SPEC
CHANGED
@@ -60,9 +60,8 @@ below.
|
|
60
60
|
the presence or absence of the
|
61
61
|
appropriate HTTP header in the
|
62
62
|
request. See
|
63
|
-
{https://tools.ietf.org/html/rfc3875#section-4.1.18
|
64
|
-
|
65
|
-
specific behavior.
|
63
|
+
{RFC3875 section 4.1.18}[https://tools.ietf.org/html/rfc3875#section-4.1.18]
|
64
|
+
for specific behavior.
|
66
65
|
In addition to this, the Rack environment must include these
|
67
66
|
Rack-specific variables:
|
68
67
|
<tt>rack.version</tt>:: The Array representing this version of Rack
|
@@ -98,12 +97,13 @@ Rack-specific variables:
|
|
98
97
|
Additional environment specifications have approved to
|
99
98
|
standardized middleware APIs. None of these are required to
|
100
99
|
be implemented by the server.
|
101
|
-
<tt>rack.session</tt>:: A hash like interface for storing
|
100
|
+
<tt>rack.session</tt>:: A hash like interface for storing
|
101
|
+
request session data.
|
102
102
|
The store must implement:
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
103
|
+
store(key, value) (aliased as []=);
|
104
|
+
fetch(key, default = nil) (aliased as []);
|
105
|
+
delete(key);
|
106
|
+
clear;
|
107
107
|
<tt>rack.logger</tt>:: A common object interface for logging messages.
|
108
108
|
The object must implement:
|
109
109
|
info(message, &block)
|
@@ -225,9 +225,9 @@ This is an HTTP status. When parsed as integer (+to_i+), it must be
|
|
225
225
|
greater than or equal to 100.
|
226
226
|
=== The Headers
|
227
227
|
The header must respond to +each+, and yield values of key and value.
|
228
|
+
The header keys must be Strings.
|
228
229
|
Special headers starting "rack." are for communicating with the
|
229
230
|
server, and must not be sent back to the client.
|
230
|
-
The header keys must be Strings.
|
231
231
|
The header must not contain a +Status+ key.
|
232
232
|
The header must conform to RFC7230 token specification, i.e. cannot
|
233
233
|
contain non-printable ASCII, DQUOTE or "(),/:;<=>?@[\]{}".
|
data/bin/rackup
CHANGED
data/example/lobster.ru
CHANGED
data/example/protectedlobster.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack'
|
2
4
|
require 'rack/lobster'
|
3
5
|
|
@@ -11,4 +13,4 @@ protected_lobster.realm = 'Lobster 2.0'
|
|
11
13
|
|
12
14
|
pretty_protected_lobster = Rack::ShowStatus.new(Rack::ShowExceptions.new(protected_lobster))
|
13
15
|
|
14
|
-
Rack::Server.start :
|
16
|
+
Rack::Server.start app: pretty_protected_lobster, Port: 9292
|
data/example/protectedlobster.ru
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rack
|
2
4
|
module Auth
|
3
5
|
# Rack::Auth::AbstractHandler implements common authentication functionality.
|
@@ -8,7 +10,7 @@ module Rack
|
|
8
10
|
|
9
11
|
attr_accessor :realm
|
10
12
|
|
11
|
-
def initialize(app, realm=nil, &authenticator)
|
13
|
+
def initialize(app, realm = nil, &authenticator)
|
12
14
|
@app, @realm, @authenticator = app, realm, authenticator
|
13
15
|
end
|
14
16
|
|
data/lib/rack/auth/basic.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack/auth/abstract/handler'
|
2
4
|
require 'rack/auth/abstract/request'
|
5
|
+
require 'base64'
|
3
6
|
|
4
7
|
module Rack
|
5
8
|
module Auth
|
@@ -45,7 +48,7 @@ module Rack
|
|
45
48
|
end
|
46
49
|
|
47
50
|
def credentials
|
48
|
-
@credentials ||=
|
51
|
+
@credentials ||= Base64.decode64(params).split(':', 2)
|
49
52
|
end
|
50
53
|
|
51
54
|
def username
|
data/lib/rack/auth/digest/md5.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack/auth/abstract/handler'
|
2
4
|
require 'rack/auth/digest/request'
|
3
5
|
require 'rack/auth/digest/params'
|
@@ -21,7 +23,7 @@ module Rack
|
|
21
23
|
|
22
24
|
attr_writer :passwords_hashed
|
23
25
|
|
24
|
-
def initialize(app, realm=nil, opaque=nil, &authenticator)
|
26
|
+
def initialize(app, realm = nil, opaque = nil, &authenticator)
|
25
27
|
@passwords_hashed = nil
|
26
28
|
if opaque.nil? and realm.respond_to? :values_at
|
27
29
|
realm, opaque, @passwords_hashed = realm.values_at :realm, :opaque, :passwords_hashed
|
@@ -47,7 +49,7 @@ module Rack
|
|
47
49
|
|
48
50
|
if valid?(auth)
|
49
51
|
if auth.nonce.stale?
|
50
|
-
return unauthorized(challenge(:
|
52
|
+
return unauthorized(challenge(stale: true))
|
51
53
|
else
|
52
54
|
env['REMOTE_USER'] = auth.username
|
53
55
|
|
@@ -61,7 +63,7 @@ module Rack
|
|
61
63
|
|
62
64
|
private
|
63
65
|
|
64
|
-
QOP = 'auth'
|
66
|
+
QOP = 'auth'
|
65
67
|
|
66
68
|
def params(hash = {})
|
67
69
|
Params.new do |params|
|
@@ -106,21 +108,21 @@ module Rack
|
|
106
108
|
alias :H :md5
|
107
109
|
|
108
110
|
def KD(secret, data)
|
109
|
-
H
|
111
|
+
H "#{secret}:#{data}"
|
110
112
|
end
|
111
113
|
|
112
114
|
def A1(auth, password)
|
113
|
-
|
115
|
+
"#{auth.username}:#{auth.realm}:#{password}"
|
114
116
|
end
|
115
117
|
|
116
118
|
def A2(auth)
|
117
|
-
|
119
|
+
"#{auth.method}:#{auth.uri}"
|
118
120
|
end
|
119
121
|
|
120
122
|
def digest(auth, password)
|
121
123
|
password_hash = passwords_hashed? ? password : H(A1(auth, password))
|
122
124
|
|
123
|
-
KD
|
125
|
+
KD password_hash, "#{auth.nonce}:#{auth.nc}:#{auth.cnonce}:#{QOP}:#{H A2(auth)}"
|
124
126
|
end
|
125
127
|
|
126
128
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'digest/md5'
|
4
|
+
require 'base64'
|
2
5
|
|
3
6
|
module Rack
|
4
7
|
module Auth
|
@@ -18,7 +21,7 @@ module Rack
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def self.parse(string)
|
21
|
-
new(*
|
24
|
+
new(*Base64.decode64(string).split(' ', 2))
|
22
25
|
end
|
23
26
|
|
24
27
|
def initialize(timestamp = Time.now, given_digest = nil)
|
@@ -26,11 +29,11 @@ module Rack
|
|
26
29
|
end
|
27
30
|
|
28
31
|
def to_s
|
29
|
-
|
32
|
+
Base64.encode64("#{@timestamp} #{digest}").strip
|
30
33
|
end
|
31
34
|
|
32
35
|
def digest
|
33
|
-
::Digest::MD5.hexdigest(
|
36
|
+
::Digest::MD5.hexdigest("#{@timestamp}:#{self.class.private_key}")
|
34
37
|
end
|
35
38
|
|
36
39
|
def valid?
|