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/README
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
= Rack, a modular Ruby webserver interface
|
|
2
|
-
|
|
3
|
-
Rack provides a minimal, modular and adaptable interface for developing
|
|
4
|
-
web applications in Ruby. By wrapping HTTP requests and responses in
|
|
5
|
-
the simplest way possible, it unifies and distills the API for web
|
|
6
|
-
servers, web frameworks, and software in between (the so-called
|
|
7
|
-
middleware) into a single method call.
|
|
8
|
-
|
|
9
|
-
The exact details of this are described in the Rack specification,
|
|
10
|
-
which all Rack applications should conform to.
|
|
11
|
-
|
|
12
|
-
== Specification changes in this release
|
|
13
|
-
|
|
14
|
-
With Rack 1.0, the Rack specification (found in SPEC) changed in the
|
|
15
|
-
following backward-incompatible ways. This was done to properly
|
|
16
|
-
support Ruby 1.9 and to deprecate some problematic techniques:
|
|
17
|
-
|
|
18
|
-
* Rack::VERSION has been pushed to [1,0].
|
|
19
|
-
* Header values must be Strings now, split on "\n".
|
|
20
|
-
* rack.input must be rewindable and support reading into a buffer,
|
|
21
|
-
wrap with Rack::RewindableInput if it isn't.
|
|
22
|
-
* Content-Length can be missing, in this case chunked transfer
|
|
23
|
-
encoding is used.
|
|
24
|
-
* Bodies can now additionally respond to #to_path with a filename to
|
|
25
|
-
be served.
|
|
26
|
-
* String bodies are deprecated and will not work with Ruby 1.9, use an
|
|
27
|
-
Array with a single String instead.
|
|
28
|
-
* rack.session is now specified.
|
|
29
|
-
|
|
30
|
-
== Supported web servers
|
|
31
|
-
|
|
32
|
-
The included *handlers* connect all kinds of web servers to Rack:
|
|
33
|
-
* Mongrel
|
|
34
|
-
* EventedMongrel
|
|
35
|
-
* SwiftipliedMongrel
|
|
36
|
-
* WEBrick
|
|
37
|
-
* FCGI
|
|
38
|
-
* CGI
|
|
39
|
-
* SCGI
|
|
40
|
-
* LiteSpeed
|
|
41
|
-
* Thin
|
|
42
|
-
|
|
43
|
-
These web servers include Rack handlers in their distributions:
|
|
44
|
-
* Ebb
|
|
45
|
-
* Fuzed
|
|
46
|
-
* Phusion Passenger (which is mod_rack for Apache and for nginx)
|
|
47
|
-
* Unicorn
|
|
48
|
-
|
|
49
|
-
Any valid Rack app will run the same on all these handlers, without
|
|
50
|
-
changing anything.
|
|
51
|
-
|
|
52
|
-
== Supported web frameworks
|
|
53
|
-
|
|
54
|
-
The included *adapters* connect Rack with existing Ruby web frameworks:
|
|
55
|
-
* Camping
|
|
56
|
-
|
|
57
|
-
These frameworks include Rack adapters in their distributions:
|
|
58
|
-
* Camping
|
|
59
|
-
* Coset
|
|
60
|
-
* Halcyon
|
|
61
|
-
* Mack
|
|
62
|
-
* Maveric
|
|
63
|
-
* Merb
|
|
64
|
-
* Racktools::SimpleApplication
|
|
65
|
-
* Ramaze
|
|
66
|
-
* Ruby on Rails
|
|
67
|
-
* Rum
|
|
68
|
-
* Sinatra
|
|
69
|
-
* Sin
|
|
70
|
-
* Vintage
|
|
71
|
-
* Waves
|
|
72
|
-
* Wee
|
|
73
|
-
|
|
74
|
-
Current links to these projects can be found at
|
|
75
|
-
http://wiki.ramaze.net/Home#other-frameworks
|
|
76
|
-
|
|
77
|
-
== Available middleware
|
|
78
|
-
|
|
79
|
-
Between the server and the framework, Rack can be customized to your
|
|
80
|
-
applications needs using middleware, for example:
|
|
81
|
-
* Rack::URLMap, to route to multiple applications inside the same process.
|
|
82
|
-
* Rack::CommonLogger, for creating Apache-style logfiles.
|
|
83
|
-
* Rack::ShowException, for catching unhandled exceptions and
|
|
84
|
-
presenting them in a nice and helpful way with clickable backtrace.
|
|
85
|
-
* Rack::File, for serving static files.
|
|
86
|
-
* ...many others!
|
|
87
|
-
|
|
88
|
-
All these components use the same interface, which is described in
|
|
89
|
-
detail in the Rack specification. These optional components can be
|
|
90
|
-
used in any way you wish.
|
|
91
|
-
|
|
92
|
-
== Convenience
|
|
93
|
-
|
|
94
|
-
If you want to develop outside of existing frameworks, implement your
|
|
95
|
-
own ones, or develop middleware, Rack provides many helpers to create
|
|
96
|
-
Rack applications quickly and without doing the same web stuff all
|
|
97
|
-
over:
|
|
98
|
-
* Rack::Request, which also provides query string parsing and
|
|
99
|
-
multipart handling.
|
|
100
|
-
* Rack::Response, for convenient generation of HTTP replies and
|
|
101
|
-
cookie handling.
|
|
102
|
-
* Rack::MockRequest and Rack::MockResponse for efficient and quick
|
|
103
|
-
testing of Rack application without real HTTP round-trips.
|
|
104
|
-
|
|
105
|
-
== rack-contrib
|
|
106
|
-
|
|
107
|
-
The plethora of useful middleware created the need for a project that
|
|
108
|
-
collects fresh Rack middleware. rack-contrib includes a variety of
|
|
109
|
-
add-on components for Rack and it is easy to contribute new modules.
|
|
110
|
-
|
|
111
|
-
* http://github.com/rack/rack-contrib
|
|
112
|
-
|
|
113
|
-
== rackup
|
|
114
|
-
|
|
115
|
-
rackup is a useful tool for running Rack applications, which uses the
|
|
116
|
-
Rack::Builder DSL to configure middleware and build up applications
|
|
117
|
-
easily.
|
|
118
|
-
|
|
119
|
-
rackup automatically figures out the environment it is run in, and
|
|
120
|
-
runs your application as FastCGI, CGI, or standalone with Mongrel or
|
|
121
|
-
WEBrick---all from the same configuration.
|
|
122
|
-
|
|
123
|
-
== Quick start
|
|
124
|
-
|
|
125
|
-
Try the lobster!
|
|
126
|
-
|
|
127
|
-
Either with the embedded WEBrick starter:
|
|
128
|
-
|
|
129
|
-
ruby -Ilib lib/rack/lobster.rb
|
|
130
|
-
|
|
131
|
-
Or with rackup:
|
|
132
|
-
|
|
133
|
-
bin/rackup -Ilib example/lobster.ru
|
|
134
|
-
|
|
135
|
-
By default, the lobster is found at http://localhost:9292.
|
|
136
|
-
|
|
137
|
-
== Installing with RubyGems
|
|
138
|
-
|
|
139
|
-
A Gem of Rack is available. You can install it with:
|
|
140
|
-
|
|
141
|
-
gem install rack
|
|
142
|
-
|
|
143
|
-
I also provide a local mirror of the gems (and development snapshots)
|
|
144
|
-
at my site:
|
|
145
|
-
|
|
146
|
-
gem install rack --source http://chneukirchen.org/releases/gems/
|
|
147
|
-
|
|
148
|
-
== Running the tests
|
|
149
|
-
|
|
150
|
-
Testing Rack requires the test/spec testing framework:
|
|
151
|
-
|
|
152
|
-
gem install test-spec
|
|
153
|
-
|
|
154
|
-
There are two rake-based test tasks:
|
|
155
|
-
|
|
156
|
-
rake test tests all the fast tests (no Handlers or Adapters)
|
|
157
|
-
rake fulltest runs all the tests
|
|
158
|
-
|
|
159
|
-
The fast testsuite has no dependencies outside of the core Ruby
|
|
160
|
-
installation and test-spec.
|
|
161
|
-
|
|
162
|
-
To run the test suite completely, you need:
|
|
163
|
-
|
|
164
|
-
* camping
|
|
165
|
-
* fcgi
|
|
166
|
-
* memcache-client
|
|
167
|
-
* mongrel
|
|
168
|
-
* ruby-openid
|
|
169
|
-
* thin
|
|
170
|
-
|
|
171
|
-
The full set of tests test FCGI access with lighttpd (on port
|
|
172
|
-
9203) so you will need lighttpd installed as well as the FCGI
|
|
173
|
-
libraries and the fcgi gem:
|
|
174
|
-
|
|
175
|
-
Download and install lighttpd:
|
|
176
|
-
|
|
177
|
-
http://www.lighttpd.net/download
|
|
178
|
-
|
|
179
|
-
Installing the FCGI libraries:
|
|
180
|
-
|
|
181
|
-
curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
|
|
182
|
-
tar xzvf fcgi-2.4.0.tar.gz
|
|
183
|
-
cd fcgi-2.4.0
|
|
184
|
-
./configure --prefix=/usr/local
|
|
185
|
-
make
|
|
186
|
-
sudo make install
|
|
187
|
-
cd ..
|
|
188
|
-
|
|
189
|
-
Installing the Ruby fcgi gem:
|
|
190
|
-
|
|
191
|
-
gem install fcgi
|
|
192
|
-
|
|
193
|
-
Furthermore, to test Memcache sessions, you need memcached (will be
|
|
194
|
-
run on port 11211) and memcache-client installed.
|
|
195
|
-
|
|
196
|
-
== History
|
|
197
|
-
|
|
198
|
-
* March 3rd, 2007: First public release 0.1.
|
|
199
|
-
|
|
200
|
-
* May 16th, 2007: Second public release 0.2.
|
|
201
|
-
* HTTP Basic authentication.
|
|
202
|
-
* Cookie Sessions.
|
|
203
|
-
* Static file handler.
|
|
204
|
-
* Improved Rack::Request.
|
|
205
|
-
* Improved Rack::Response.
|
|
206
|
-
* Added Rack::ShowStatus, for better default error messages.
|
|
207
|
-
* Bug fixes in the Camping adapter.
|
|
208
|
-
* Removed Rails adapter, was too alpha.
|
|
209
|
-
|
|
210
|
-
* February 26th, 2008: Third public release 0.3.
|
|
211
|
-
* LiteSpeed handler, by Adrian Madrid.
|
|
212
|
-
* SCGI handler, by Jeremy Evans.
|
|
213
|
-
* Pool sessions, by blink.
|
|
214
|
-
* OpenID authentication, by blink.
|
|
215
|
-
* :Port and :File options for opening FastCGI sockets, by blink.
|
|
216
|
-
* Last-Modified HTTP header for Rack::File, by blink.
|
|
217
|
-
* Rack::Builder#use now accepts blocks, by Corey Jewett.
|
|
218
|
-
(See example/protectedlobster.ru)
|
|
219
|
-
* HTTP status 201 can contain a Content-Type and a body now.
|
|
220
|
-
* Many bugfixes, especially related to Cookie handling.
|
|
221
|
-
|
|
222
|
-
* August 21st, 2008: Fourth public release 0.4.
|
|
223
|
-
* New middleware, Rack::Deflater, by Christoffer Sawicki.
|
|
224
|
-
* OpenID authentication now needs ruby-openid 2.
|
|
225
|
-
* New Memcache sessions, by blink.
|
|
226
|
-
* Explicit EventedMongrel handler, by Joshua Peek <josh@joshpeek.com>
|
|
227
|
-
* Rack::Reloader is not loaded in rackup development mode.
|
|
228
|
-
* rackup can daemonize with -D.
|
|
229
|
-
* Many bugfixes, especially for pool sessions, URLMap, thread safety
|
|
230
|
-
and tempfile handling.
|
|
231
|
-
* Improved tests.
|
|
232
|
-
* Rack moved to Git.
|
|
233
|
-
|
|
234
|
-
* January 6th, 2009: Fifth public release 0.9.
|
|
235
|
-
* Rack is now managed by the Rack Core Team.
|
|
236
|
-
* Rack::Lint is stricter and follows the HTTP RFCs more closely.
|
|
237
|
-
* Added ConditionalGet middleware.
|
|
238
|
-
* Added ContentLength middleware.
|
|
239
|
-
* Added Deflater middleware.
|
|
240
|
-
* Added Head middleware.
|
|
241
|
-
* Added MethodOverride middleware.
|
|
242
|
-
* Rack::Mime now provides popular MIME-types and their extension.
|
|
243
|
-
* Mongrel Header now streams.
|
|
244
|
-
* Added Thin handler.
|
|
245
|
-
* Official support for swiftiplied Mongrel.
|
|
246
|
-
* Secure cookies.
|
|
247
|
-
* Made HeaderHash case-preserving.
|
|
248
|
-
* Many bugfixes and small improvements.
|
|
249
|
-
|
|
250
|
-
* January 9th, 2009: Sixth public release 0.9.1.
|
|
251
|
-
* Fix directory traversal exploits in Rack::File and Rack::Directory.
|
|
252
|
-
|
|
253
|
-
* April 25th, 2009: Seventh public release 1.0.0.
|
|
254
|
-
* SPEC change: Rack::VERSION has been pushed to [1,0].
|
|
255
|
-
* SPEC change: header values must be Strings now, split on "\n".
|
|
256
|
-
* SPEC change: Content-Length can be missing, in this case chunked transfer
|
|
257
|
-
encoding is used.
|
|
258
|
-
* SPEC change: rack.input must be rewindable and support reading into
|
|
259
|
-
a buffer, wrap with Rack::RewindableInput if it isn't.
|
|
260
|
-
* SPEC change: rack.session is now specified.
|
|
261
|
-
* SPEC change: Bodies can now additionally respond to #to_path with
|
|
262
|
-
a filename to be served.
|
|
263
|
-
* NOTE: String bodies break in 1.9, use an Array consisting of a
|
|
264
|
-
single String instead.
|
|
265
|
-
* New middleware Rack::Lock.
|
|
266
|
-
* New middleware Rack::ContentType.
|
|
267
|
-
* Rack::Reloader has been rewritten.
|
|
268
|
-
* Major update to Rack::Auth::OpenID.
|
|
269
|
-
* Support for nested parameter parsing in Rack::Response.
|
|
270
|
-
* Support for redirects in Rack::Response.
|
|
271
|
-
* HttpOnly cookie support in Rack::Response.
|
|
272
|
-
* The Rakefile has been rewritten.
|
|
273
|
-
* Many bugfixes and small improvements.
|
|
274
|
-
|
|
275
|
-
* October 18th, 2009: Eighth public release 1.0.1.
|
|
276
|
-
* Bump remainder of rack.versions.
|
|
277
|
-
* Support the pure Ruby FCGI implementation.
|
|
278
|
-
* Fix for form names containing "=": split first then unescape components
|
|
279
|
-
* Fixes the handling of the filename parameter with semicolons in names.
|
|
280
|
-
* Add anchor to nested params parsing regexp to prevent stack overflows
|
|
281
|
-
* Use more compatible gzip write api instead of "<<".
|
|
282
|
-
* Make sure that Reloader doesn't break when executed via ruby -e
|
|
283
|
-
* Make sure WEBrick respects the :Host option
|
|
284
|
-
* Many Ruby 1.9 fixes.
|
|
285
|
-
|
|
286
|
-
== Contact
|
|
287
|
-
|
|
288
|
-
Please mail bugs, suggestions and patches to
|
|
289
|
-
<mailto:rack-devel@googlegroups.com>.
|
|
290
|
-
|
|
291
|
-
Mailing list archives are available at
|
|
292
|
-
<http://groups.google.com/group/rack-devel>.
|
|
293
|
-
|
|
294
|
-
There is a bug tracker at <http://rack.lighthouseapp.com/>.
|
|
295
|
-
|
|
296
|
-
Git repository (send Git patches to the mailing list):
|
|
297
|
-
* http://github.com/rack/rack
|
|
298
|
-
* http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack.git
|
|
299
|
-
|
|
300
|
-
You are also welcome to join the #rack channel on irc.freenode.net.
|
|
301
|
-
|
|
302
|
-
== Thanks
|
|
303
|
-
|
|
304
|
-
The Rack Core Team, consisting of
|
|
305
|
-
|
|
306
|
-
* Christian Neukirchen (chneukirchen)
|
|
307
|
-
* James Tucker (raggi)
|
|
308
|
-
* Josh Peek (josh)
|
|
309
|
-
* Michael Fellinger (manveru)
|
|
310
|
-
* Ryan Tomayko (rtomayko)
|
|
311
|
-
* Scytrin dai Kinthra (scytrin)
|
|
312
|
-
|
|
313
|
-
would like to thank:
|
|
314
|
-
|
|
315
|
-
* Adrian Madrid, for the LiteSpeed handler.
|
|
316
|
-
* Christoffer Sawicki, for the first Rails adapter and Rack::Deflater.
|
|
317
|
-
* Tim Fletcher, for the HTTP authentication code.
|
|
318
|
-
* Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
|
|
319
|
-
* Armin Ronacher, for the logo and racktools.
|
|
320
|
-
* Aredridel, Ben Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd,
|
|
321
|
-
Tom Robinson, Phil Hagelberg, and S. Brent Faulkner for bug fixing
|
|
322
|
-
and other improvements.
|
|
323
|
-
* Brian Candler, for Rack::ContentType.
|
|
324
|
-
* Graham Batty, for improved handler loading.
|
|
325
|
-
* Stephen Bannasch, for bug reports and documentation.
|
|
326
|
-
* Gary Wright, for proposing a better Rack::Response interface.
|
|
327
|
-
* Jonathan Buch, for improvements regarding Rack::Response.
|
|
328
|
-
* Armin Röhrl, for tracking down bugs in the Cookie generator.
|
|
329
|
-
* Alexander Kellett for testing the Gem and reviewing the announcement.
|
|
330
|
-
* Marcus Rückert, for help with configuring and debugging lighttpd.
|
|
331
|
-
* The WSGI team for the well-done and documented work they've done and
|
|
332
|
-
Rack builds up on.
|
|
333
|
-
* All bug reporters and patch contributers not mentioned above.
|
|
334
|
-
|
|
335
|
-
== Copyright
|
|
336
|
-
|
|
337
|
-
Copyright (C) 2007, 2008, 2009 Christian Neukirchen <http://purl.org/net/chneukirchen>
|
|
338
|
-
|
|
339
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
340
|
-
of this software and associated documentation files (the "Software"), to
|
|
341
|
-
deal in the Software without restriction, including without limitation the
|
|
342
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
343
|
-
sell copies of the Software, and to permit persons to whom the Software is
|
|
344
|
-
furnished to do so, subject to the following conditions:
|
|
345
|
-
|
|
346
|
-
The above copyright notice and this permission notice shall be included in
|
|
347
|
-
all copies or substantial portions of the Software.
|
|
348
|
-
|
|
349
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
350
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
351
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
352
|
-
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
353
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
354
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
355
|
-
|
|
356
|
-
== Links
|
|
357
|
-
|
|
358
|
-
Rack:: <http://rack.rubyforge.org/>
|
|
359
|
-
Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
|
|
360
|
-
Official Rack repositories:: <http://github.com/rack>
|
|
361
|
-
rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
|
|
362
|
-
|
|
363
|
-
Christian Neukirchen:: <http://chneukirchen.org/>
|
|
364
|
-
|
data/SPEC
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
This specification aims to formalize the Rack protocol. You
|
|
2
|
-
can (and should) use Rack::Lint to enforce it.
|
|
3
|
-
When you develop middleware, be sure to add a Lint before and
|
|
4
|
-
after to catch all mistakes.
|
|
5
|
-
= Rack applications
|
|
6
|
-
A Rack application is an Ruby object (not a class) that
|
|
7
|
-
responds to +call+.
|
|
8
|
-
It takes exactly one argument, the *environment*
|
|
9
|
-
and returns an Array of exactly three values:
|
|
10
|
-
The *status*,
|
|
11
|
-
the *headers*,
|
|
12
|
-
and the *body*.
|
|
13
|
-
== The Environment
|
|
14
|
-
The environment must be an true instance of Hash (no
|
|
15
|
-
subclassing allowed) that includes CGI-like headers.
|
|
16
|
-
The application is free to modify the environment.
|
|
17
|
-
The environment is required to include these variables
|
|
18
|
-
(adopted from PEP333), except when they'd be empty, but see
|
|
19
|
-
below.
|
|
20
|
-
<tt>REQUEST_METHOD</tt>:: The HTTP request method, such as
|
|
21
|
-
"GET" or "POST". This cannot ever
|
|
22
|
-
be an empty string, and so is
|
|
23
|
-
always required.
|
|
24
|
-
<tt>SCRIPT_NAME</tt>:: The initial portion of the request
|
|
25
|
-
URL's "path" that corresponds to the
|
|
26
|
-
application object, so that the
|
|
27
|
-
application knows its virtual
|
|
28
|
-
"location". This may be an empty
|
|
29
|
-
string, if the application corresponds
|
|
30
|
-
to the "root" of the server.
|
|
31
|
-
<tt>PATH_INFO</tt>:: The remainder of the request URL's
|
|
32
|
-
"path", designating the virtual
|
|
33
|
-
"location" of the request's target
|
|
34
|
-
within the application. This may be an
|
|
35
|
-
empty string, if the request URL targets
|
|
36
|
-
the application root and does not have a
|
|
37
|
-
trailing slash. This value may be
|
|
38
|
-
percent-encoded when I originating from
|
|
39
|
-
a URL.
|
|
40
|
-
<tt>QUERY_STRING</tt>:: The portion of the request URL that
|
|
41
|
-
follows the <tt>?</tt>, if any. May be
|
|
42
|
-
empty, but is always required!
|
|
43
|
-
<tt>SERVER_NAME</tt>, <tt>SERVER_PORT</tt>:: When combined with <tt>SCRIPT_NAME</tt> and <tt>PATH_INFO</tt>, these variables can be used to complete the URL. Note, however, that <tt>HTTP_HOST</tt>, if present, should be used in preference to <tt>SERVER_NAME</tt> for reconstructing the request URL. <tt>SERVER_NAME</tt> and <tt>SERVER_PORT</tt> can never be empty strings, and so are always required.
|
|
44
|
-
<tt>HTTP_</tt> Variables:: Variables corresponding to the
|
|
45
|
-
client-supplied HTTP request
|
|
46
|
-
headers (i.e., variables whose
|
|
47
|
-
names begin with <tt>HTTP_</tt>). The
|
|
48
|
-
presence or absence of these
|
|
49
|
-
variables should correspond with
|
|
50
|
-
the presence or absence of the
|
|
51
|
-
appropriate HTTP header in the
|
|
52
|
-
request.
|
|
53
|
-
In addition to this, the Rack environment must include these
|
|
54
|
-
Rack-specific variables:
|
|
55
|
-
<tt>rack.version</tt>:: The Array [1,0], representing this version of Rack.
|
|
56
|
-
<tt>rack.url_scheme</tt>:: +http+ or +https+, depending on the request URL.
|
|
57
|
-
<tt>rack.input</tt>:: See below, the input stream.
|
|
58
|
-
<tt>rack.errors</tt>:: See below, the error stream.
|
|
59
|
-
<tt>rack.multithread</tt>:: true if the application object may be simultaneously invoked by another thread in the same process, false otherwise.
|
|
60
|
-
<tt>rack.multiprocess</tt>:: true if an equivalent application object may be simultaneously invoked by another process, false otherwise.
|
|
61
|
-
<tt>rack.run_once</tt>:: true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar).
|
|
62
|
-
Additional environment specifications have approved to
|
|
63
|
-
standardized middleware APIs. None of these are required to
|
|
64
|
-
be implemented by the server.
|
|
65
|
-
<tt>rack.session</tt>:: A hash like interface for storing request session data.
|
|
66
|
-
The store must implement:
|
|
67
|
-
store(key, value) (aliased as []=);
|
|
68
|
-
fetch(key, default = nil) (aliased as []);
|
|
69
|
-
delete(key);
|
|
70
|
-
clear;
|
|
71
|
-
The server or the application can store their own data in the
|
|
72
|
-
environment, too. The keys must contain at least one dot,
|
|
73
|
-
and should be prefixed uniquely. The prefix <tt>rack.</tt>
|
|
74
|
-
is reserved for use with the Rack core distribution and other
|
|
75
|
-
accepted specifications and must not be used otherwise.
|
|
76
|
-
The environment must not contain the keys
|
|
77
|
-
<tt>HTTP_CONTENT_TYPE</tt> or <tt>HTTP_CONTENT_LENGTH</tt>
|
|
78
|
-
(use the versions without <tt>HTTP_</tt>).
|
|
79
|
-
The CGI keys (named without a period) must have String values.
|
|
80
|
-
There are the following restrictions:
|
|
81
|
-
* <tt>rack.version</tt> must be an array of Integers.
|
|
82
|
-
* <tt>rack.url_scheme</tt> must either be +http+ or +https+.
|
|
83
|
-
* There must be a valid input stream in <tt>rack.input</tt>.
|
|
84
|
-
* There must be a valid error stream in <tt>rack.errors</tt>.
|
|
85
|
-
* The <tt>REQUEST_METHOD</tt> must be a valid token.
|
|
86
|
-
* The <tt>SCRIPT_NAME</tt>, if non-empty, must start with <tt>/</tt>
|
|
87
|
-
* The <tt>PATH_INFO</tt>, if non-empty, must start with <tt>/</tt>
|
|
88
|
-
* The <tt>CONTENT_LENGTH</tt>, if given, must consist of digits only.
|
|
89
|
-
* One of <tt>SCRIPT_NAME</tt> or <tt>PATH_INFO</tt> must be
|
|
90
|
-
set. <tt>PATH_INFO</tt> should be <tt>/</tt> if
|
|
91
|
-
<tt>SCRIPT_NAME</tt> is empty.
|
|
92
|
-
<tt>SCRIPT_NAME</tt> never should be <tt>/</tt>, but instead be empty.
|
|
93
|
-
=== The Input Stream
|
|
94
|
-
The input stream is an IO-like object which contains the raw HTTP
|
|
95
|
-
POST data.
|
|
96
|
-
When applicable, its external encoding must be "ASCII-8BIT" and it
|
|
97
|
-
must be opened in binary mode, for Ruby 1.9 compatibility.
|
|
98
|
-
The input stream must respond to +gets+, +each+, +read+ and +rewind+.
|
|
99
|
-
* +gets+ must be called without arguments and return a string,
|
|
100
|
-
or +nil+ on EOF.
|
|
101
|
-
* +read+ behaves like IO#read. Its signature is <tt>read([length, [buffer]])</tt>.
|
|
102
|
-
If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must
|
|
103
|
-
be a String and may not be nil. If +length+ is given and not nil, then this method
|
|
104
|
-
reads at most +length+ bytes from the input stream. If +length+ is not given or nil,
|
|
105
|
-
then this method reads all data until EOF.
|
|
106
|
-
When EOF is reached, this method returns nil if +length+ is given and not nil, or ""
|
|
107
|
-
if +length+ is not given or is nil.
|
|
108
|
-
If +buffer+ is given, then the read data will be placed into +buffer+ instead of a
|
|
109
|
-
newly created String object.
|
|
110
|
-
* +each+ must be called without arguments and only yield Strings.
|
|
111
|
-
* +rewind+ must be called without arguments. It rewinds the input
|
|
112
|
-
stream back to the beginning. It must not raise Errno::ESPIPE:
|
|
113
|
-
that is, it may not be a pipe or a socket. Therefore, handler
|
|
114
|
-
developers must buffer the input data into some rewindable object
|
|
115
|
-
if the underlying input stream is not rewindable.
|
|
116
|
-
* +close+ must never be called on the input stream.
|
|
117
|
-
=== The Error Stream
|
|
118
|
-
The error stream must respond to +puts+, +write+ and +flush+.
|
|
119
|
-
* +puts+ must be called with a single argument that responds to +to_s+.
|
|
120
|
-
* +write+ must be called with a single argument that is a String.
|
|
121
|
-
* +flush+ must be called without arguments and must be called
|
|
122
|
-
in order to make the error appear for sure.
|
|
123
|
-
* +close+ must never be called on the error stream.
|
|
124
|
-
== The Response
|
|
125
|
-
=== The Status
|
|
126
|
-
This is an HTTP status. When parsed as integer (+to_i+), it must be
|
|
127
|
-
greater than or equal to 100.
|
|
128
|
-
=== The Headers
|
|
129
|
-
The header must respond to +each+, and yield values of key and value.
|
|
130
|
-
The header keys must be Strings.
|
|
131
|
-
The header must not contain a +Status+ key,
|
|
132
|
-
contain keys with <tt>:</tt> or newlines in their name,
|
|
133
|
-
contain keys names that end in <tt>-</tt> or <tt>_</tt>,
|
|
134
|
-
but only contain keys that consist of
|
|
135
|
-
letters, digits, <tt>_</tt> or <tt>-</tt> and start with a letter.
|
|
136
|
-
The values of the header must be Strings,
|
|
137
|
-
consisting of lines (for multiple header values, e.g. multiple
|
|
138
|
-
<tt>Set-Cookie</tt> values) seperated by "\n".
|
|
139
|
-
The lines must not contain characters below 037.
|
|
140
|
-
=== The Content-Type
|
|
141
|
-
There must be a <tt>Content-Type</tt>, except when the
|
|
142
|
-
+Status+ is 1xx, 204 or 304, in which case there must be none
|
|
143
|
-
given.
|
|
144
|
-
=== The Content-Length
|
|
145
|
-
There must not be a <tt>Content-Length</tt> header when the
|
|
146
|
-
+Status+ is 1xx, 204 or 304.
|
|
147
|
-
=== The Body
|
|
148
|
-
The Body must respond to +each+
|
|
149
|
-
and must only yield String values.
|
|
150
|
-
The Body itself should not be an instance of String, as this will
|
|
151
|
-
break in Ruby 1.9.
|
|
152
|
-
If the Body responds to +close+, it will be called after iteration.
|
|
153
|
-
If the Body responds to +to_path+, it must return a String
|
|
154
|
-
identifying the location of a file whose contents are identical
|
|
155
|
-
to that produced by calling +each+; this may be used by the
|
|
156
|
-
server as an alternative, possibly more efficient way to
|
|
157
|
-
transport the response.
|
|
158
|
-
The Body commonly is an Array of Strings, the application
|
|
159
|
-
instance itself, or a File-like object.
|
|
160
|
-
== Thanks
|
|
161
|
-
Some parts of this specification are adopted from PEP333: Python
|
|
162
|
-
Web Server Gateway Interface
|
|
163
|
-
v1.0 (http://www.python.org/dev/peps/pep-0333/). I'd like to thank
|
|
164
|
-
everyone involved in that effort.
|
data/lib/rack/adapter/camping.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Rack
|
|
2
|
-
module Adapter
|
|
3
|
-
class Camping
|
|
4
|
-
def initialize(app)
|
|
5
|
-
@app = app
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def call(env)
|
|
9
|
-
env["PATH_INFO"] ||= ""
|
|
10
|
-
env["SCRIPT_NAME"] ||= ""
|
|
11
|
-
controller = @app.run(env['rack.input'], env)
|
|
12
|
-
h = controller.headers
|
|
13
|
-
h.each_pair do |k,v|
|
|
14
|
-
if v.kind_of? URI
|
|
15
|
-
h[k] = v.to_s
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
[controller.status, controller.headers, [controller.body.to_s]]
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|