rack 2.0.9.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +808 -0
  3. data/CONTRIBUTING.md +142 -0
  4. data/{COPYING → MIT-LICENSE} +4 -2
  5. data/README.md +293 -0
  6. data/SPEC.rdoc +340 -0
  7. data/lib/rack/auth/abstract/handler.rb +6 -2
  8. data/lib/rack/auth/abstract/request.rb +4 -2
  9. data/lib/rack/auth/basic.rb +7 -4
  10. data/lib/rack/auth/digest/md5.rb +1 -129
  11. data/lib/rack/auth/digest/nonce.rb +1 -51
  12. data/lib/rack/auth/digest/params.rb +1 -52
  13. data/lib/rack/auth/digest/request.rb +1 -41
  14. data/lib/rack/auth/digest.rb +256 -0
  15. data/lib/rack/body_proxy.rb +18 -15
  16. data/lib/rack/builder.rb +151 -40
  17. data/lib/rack/cascade.rb +30 -12
  18. data/lib/rack/chunked.rb +74 -23
  19. data/lib/rack/common_logger.rb +49 -36
  20. data/lib/rack/conditional_get.rb +33 -26
  21. data/lib/rack/config.rb +2 -0
  22. data/lib/rack/constants.rb +63 -0
  23. data/lib/rack/content_length.rb +13 -16
  24. data/lib/rack/content_type.rb +12 -8
  25. data/lib/rack/deflater.rb +84 -45
  26. data/lib/rack/directory.rb +90 -64
  27. data/lib/rack/etag.rb +17 -23
  28. data/lib/rack/events.rb +23 -20
  29. data/lib/rack/file.rb +5 -172
  30. data/lib/rack/files.rb +216 -0
  31. data/lib/rack/head.rb +10 -9
  32. data/lib/rack/headers.rb +154 -0
  33. data/lib/rack/lint.rb +786 -645
  34. data/lib/rack/lock.rb +4 -6
  35. data/lib/rack/logger.rb +4 -0
  36. data/lib/rack/media_type.rb +10 -5
  37. data/lib/rack/method_override.rb +8 -2
  38. data/lib/rack/mime.rb +17 -1
  39. data/lib/rack/mock.rb +2 -195
  40. data/lib/rack/mock_request.rb +166 -0
  41. data/lib/rack/mock_response.rb +126 -0
  42. data/lib/rack/multipart/generator.rb +21 -15
  43. data/lib/rack/multipart/parser.rb +161 -118
  44. data/lib/rack/multipart/uploaded_file.rb +19 -7
  45. data/lib/rack/multipart.rb +23 -41
  46. data/lib/rack/null_logger.rb +11 -0
  47. data/lib/rack/query_parser.rb +126 -65
  48. data/lib/rack/recursive.rb +9 -5
  49. data/lib/rack/reloader.rb +6 -4
  50. data/lib/rack/request.rb +331 -74
  51. data/lib/rack/response.rb +223 -70
  52. data/lib/rack/rewindable_input.rb +28 -8
  53. data/lib/rack/runtime.rb +11 -8
  54. data/lib/rack/sendfile.rb +42 -33
  55. data/lib/rack/show_exceptions.rb +35 -18
  56. data/lib/rack/show_status.rb +25 -15
  57. data/lib/rack/static.rb +30 -18
  58. data/lib/rack/tempfile_reaper.rb +16 -5
  59. data/lib/rack/urlmap.rb +14 -6
  60. data/lib/rack/utils.rb +268 -260
  61. data/lib/rack/version.rb +34 -0
  62. data/lib/rack.rb +15 -92
  63. metadata +44 -207
  64. data/HISTORY.md +0 -520
  65. data/README.rdoc +0 -316
  66. data/Rakefile +0 -116
  67. data/SPEC +0 -263
  68. data/bin/rackup +0 -4
  69. data/contrib/rack.png +0 -0
  70. data/contrib/rack.svg +0 -150
  71. data/contrib/rack_logo.svg +0 -164
  72. data/contrib/rdoc.css +0 -412
  73. data/example/lobster.ru +0 -4
  74. data/example/protectedlobster.rb +0 -14
  75. data/example/protectedlobster.ru +0 -8
  76. data/lib/rack/handler/cgi.rb +0 -60
  77. data/lib/rack/handler/fastcgi.rb +0 -100
  78. data/lib/rack/handler/lsws.rb +0 -61
  79. data/lib/rack/handler/scgi.rb +0 -70
  80. data/lib/rack/handler/thin.rb +0 -36
  81. data/lib/rack/handler/webrick.rb +0 -120
  82. data/lib/rack/handler.rb +0 -99
  83. data/lib/rack/lobster.rb +0 -70
  84. data/lib/rack/server.rb +0 -395
  85. data/lib/rack/session/abstract/id.rb +0 -510
  86. data/lib/rack/session/cookie.rb +0 -204
  87. data/lib/rack/session/memcache.rb +0 -99
  88. data/lib/rack/session/pool.rb +0 -83
  89. data/rack.gemspec +0 -34
  90. data/test/builder/an_underscore_app.rb +0 -5
  91. data/test/builder/anything.rb +0 -5
  92. data/test/builder/comment.ru +0 -4
  93. data/test/builder/end.ru +0 -5
  94. data/test/builder/line.ru +0 -1
  95. data/test/builder/options.ru +0 -2
  96. data/test/cgi/assets/folder/test.js +0 -1
  97. data/test/cgi/assets/fonts/font.eot +0 -1
  98. data/test/cgi/assets/images/image.png +0 -1
  99. data/test/cgi/assets/index.html +0 -1
  100. data/test/cgi/assets/javascripts/app.js +0 -1
  101. data/test/cgi/assets/stylesheets/app.css +0 -1
  102. data/test/cgi/lighttpd.conf +0 -26
  103. data/test/cgi/rackup_stub.rb +0 -6
  104. data/test/cgi/sample_rackup.ru +0 -5
  105. data/test/cgi/test +0 -9
  106. data/test/cgi/test+directory/test+file +0 -1
  107. data/test/cgi/test.fcgi +0 -9
  108. data/test/cgi/test.gz +0 -0
  109. data/test/cgi/test.ru +0 -5
  110. data/test/gemloader.rb +0 -10
  111. data/test/helper.rb +0 -34
  112. data/test/multipart/bad_robots +0 -259
  113. data/test/multipart/binary +0 -0
  114. data/test/multipart/content_type_and_no_filename +0 -6
  115. data/test/multipart/empty +0 -10
  116. data/test/multipart/fail_16384_nofile +0 -814
  117. data/test/multipart/file1.txt +0 -1
  118. data/test/multipart/filename_and_modification_param +0 -7
  119. data/test/multipart/filename_and_no_name +0 -6
  120. data/test/multipart/filename_with_encoded_words +0 -7
  121. data/test/multipart/filename_with_escaped_quotes +0 -6
  122. data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
  123. data/test/multipart/filename_with_null_byte +0 -7
  124. data/test/multipart/filename_with_percent_escaped_quotes +0 -6
  125. data/test/multipart/filename_with_single_quote +0 -7
  126. data/test/multipart/filename_with_unescaped_percentages +0 -6
  127. data/test/multipart/filename_with_unescaped_percentages2 +0 -6
  128. data/test/multipart/filename_with_unescaped_percentages3 +0 -6
  129. data/test/multipart/filename_with_unescaped_quotes +0 -6
  130. data/test/multipart/ie +0 -6
  131. data/test/multipart/invalid_character +0 -6
  132. data/test/multipart/mixed_files +0 -21
  133. data/test/multipart/nested +0 -10
  134. data/test/multipart/none +0 -9
  135. data/test/multipart/quoted +0 -15
  136. data/test/multipart/rack-logo.png +0 -0
  137. data/test/multipart/semicolon +0 -6
  138. data/test/multipart/text +0 -15
  139. data/test/multipart/three_files_three_fields +0 -31
  140. data/test/multipart/unity3d_wwwform +0 -11
  141. data/test/multipart/webkit +0 -32
  142. data/test/rackup/config.ru +0 -31
  143. data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
  144. data/test/spec_auth_basic.rb +0 -89
  145. data/test/spec_auth_digest.rb +0 -260
  146. data/test/spec_body_proxy.rb +0 -85
  147. data/test/spec_builder.rb +0 -233
  148. data/test/spec_cascade.rb +0 -63
  149. data/test/spec_cgi.rb +0 -84
  150. data/test/spec_chunked.rb +0 -103
  151. data/test/spec_common_logger.rb +0 -107
  152. data/test/spec_conditional_get.rb +0 -103
  153. data/test/spec_config.rb +0 -23
  154. data/test/spec_content_length.rb +0 -86
  155. data/test/spec_content_type.rb +0 -46
  156. data/test/spec_deflater.rb +0 -375
  157. data/test/spec_directory.rb +0 -148
  158. data/test/spec_etag.rb +0 -108
  159. data/test/spec_events.rb +0 -133
  160. data/test/spec_fastcgi.rb +0 -85
  161. data/test/spec_file.rb +0 -264
  162. data/test/spec_handler.rb +0 -57
  163. data/test/spec_head.rb +0 -46
  164. data/test/spec_lint.rb +0 -520
  165. data/test/spec_lobster.rb +0 -59
  166. data/test/spec_lock.rb +0 -204
  167. data/test/spec_logger.rb +0 -24
  168. data/test/spec_media_type.rb +0 -42
  169. data/test/spec_method_override.rb +0 -110
  170. data/test/spec_mime.rb +0 -51
  171. data/test/spec_mock.rb +0 -359
  172. data/test/spec_multipart.rb +0 -721
  173. data/test/spec_null_logger.rb +0 -21
  174. data/test/spec_recursive.rb +0 -75
  175. data/test/spec_request.rb +0 -1423
  176. data/test/spec_response.rb +0 -528
  177. data/test/spec_rewindable_input.rb +0 -128
  178. data/test/spec_runtime.rb +0 -50
  179. data/test/spec_sendfile.rb +0 -125
  180. data/test/spec_server.rb +0 -193
  181. data/test/spec_session_abstract_id.rb +0 -31
  182. data/test/spec_session_abstract_session_hash.rb +0 -45
  183. data/test/spec_session_cookie.rb +0 -442
  184. data/test/spec_session_memcache.rb +0 -357
  185. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  186. data/test/spec_session_pool.rb +0 -247
  187. data/test/spec_show_exceptions.rb +0 -93
  188. data/test/spec_show_status.rb +0 -104
  189. data/test/spec_static.rb +0 -184
  190. data/test/spec_tempfile_reaper.rb +0 -64
  191. data/test/spec_thin.rb +0 -96
  192. data/test/spec_urlmap.rb +0 -237
  193. data/test/spec_utils.rb +0 -742
  194. data/test/spec_version.rb +0 -11
  195. data/test/spec_webrick.rb +0 -206
  196. data/test/static/another/index.html +0 -1
  197. data/test/static/foo.html +0 -1
  198. data/test/static/index.html +0 -1
  199. data/test/testrequest.rb +0 -78
  200. data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
  201. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
data/README.rdoc DELETED
@@ -1,316 +0,0 @@
1
- = Rack, a modular Ruby webserver interface {<img src="https://secure.travis-ci.org/rack/rack.svg" alt="Build Status" />}[http://travis-ci.org/rack/rack] {<img src="https://gemnasium.com/rack/rack.svg" alt="Dependency Status" />}[https://gemnasium.com/rack/rack]
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
- == Supported web servers
13
-
14
- The included *handlers* connect all kinds of web servers to Rack:
15
- * WEBrick
16
- * FCGI
17
- * CGI
18
- * SCGI
19
- * LiteSpeed
20
- * Thin
21
-
22
- These web servers include Rack handlers in their distributions:
23
- * Ebb
24
- * Fuzed
25
- * Glassfish v3
26
- * Phusion Passenger (which is mod_rack for Apache and for nginx)
27
- * Puma
28
- * Reel
29
- * Unicorn
30
- * unixrack
31
- * uWSGI
32
- * yahns
33
-
34
- Any valid Rack app will run the same on all these handlers, without
35
- changing anything.
36
-
37
- == Supported web frameworks
38
-
39
- These frameworks include Rack adapters in their distributions:
40
- * Camping
41
- * Coset
42
- * Espresso
43
- * Halcyon
44
- * Mack
45
- * Maveric
46
- * Merb
47
- * Racktools::SimpleApplication
48
- * Ramaze
49
- * Ruby on Rails
50
- * Rum
51
- * Sinatra
52
- * Sin
53
- * Vintage
54
- * Waves
55
- * Wee
56
- * ... and many others.
57
-
58
- == Available middleware
59
-
60
- Between the server and the framework, Rack can be customized to your
61
- applications needs using middleware, for example:
62
- * Rack::URLMap, to route to multiple applications inside the same process.
63
- * Rack::CommonLogger, for creating Apache-style logfiles.
64
- * Rack::ShowException, for catching unhandled exceptions and
65
- presenting them in a nice and helpful way with clickable backtrace.
66
- * Rack::File, for serving static files.
67
- * ...many others!
68
-
69
- All these components use the same interface, which is described in
70
- detail in the Rack specification. These optional components can be
71
- used in any way you wish.
72
-
73
- == Convenience
74
-
75
- 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
78
- over:
79
- * Rack::Request, which also provides query string parsing and
80
- multipart handling.
81
- * Rack::Response, for convenient generation of HTTP replies and
82
- cookie handling.
83
- * Rack::MockRequest and Rack::MockResponse for efficient and quick
84
- testing of Rack application without real HTTP round-trips.
85
-
86
- == rack-contrib
87
-
88
- 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.
91
-
92
- * https://github.com/rack/rack-contrib
93
-
94
- == rackup
95
-
96
- rackup is a useful tool for running Rack applications, which uses the
97
- Rack::Builder DSL to configure middleware and build up applications
98
- easily.
99
-
100
- rackup automatically figures out the environment it is run in, and
101
- runs your application as FastCGI, CGI, or WEBrick---all from the
102
- same configuration.
103
-
104
- == Quick start
105
-
106
- Try the lobster!
107
-
108
- Either with the embedded WEBrick starter:
109
-
110
- ruby -Ilib lib/rack/lobster.rb
111
-
112
- Or with rackup:
113
-
114
- bin/rackup -Ilib example/lobster.ru
115
-
116
- By default, the lobster is found at http://localhost:9292.
117
-
118
- == Installing with RubyGems
119
-
120
- A Gem of Rack is available at rubygems.org. You can install it with:
121
-
122
- gem install rack
123
-
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
- == Running the tests
130
-
131
- Testing Rack requires the bacon testing framework:
132
-
133
- bundle install --without extra # to be able to run the fast tests
134
-
135
- Or:
136
-
137
- bundle install # this assumes that you have installed native extensions!
138
-
139
- There is a rake-based test task:
140
-
141
- rake test tests all the tests
142
-
143
- The testsuite has no dependencies outside of the core Ruby
144
- installation and bacon.
145
-
146
- To run the test suite completely, you need:
147
-
148
- * fcgi
149
- * memcache-client
150
- * thin
151
-
152
- The full set of tests test FCGI access with lighttpd (on port
153
- 9203) so you will need lighttpd installed as well as the FCGI
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.
176
-
177
- == Configuration
178
-
179
- Several parameters can be modified on Rack::Utils to configure Rack behaviour.
180
-
181
- e.g:
182
-
183
- Rack::Utils.key_space_limit = 128
184
-
185
- === key_space_limit
186
-
187
- The default number of bytes to allow a single parameter key to take up.
188
- This helps prevent a rogue client from flooding a Request.
189
-
190
- Default to 65536 characters (4 kiB in worst case).
191
-
192
- === multipart_file_limit
193
-
194
- The maximum number of parts with a filename a request can contain.
195
- Accepting too many part can lead to the server running out of file handles.
196
-
197
- The default is 128, which means that a single request can't upload more than 128 files at once.
198
-
199
- Set to 0 for no limit.
200
-
201
- Can also be set via the +RACK_MULTIPART_FILE_LIMIT+ environment variable.
202
-
203
- (This is also aliased as +multipart_part_limit+ and +RACK_MULTIPART_PART_LIMIT+ for compatibility)
204
-
205
- === 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.
214
-
215
- Can also be set via the +RACK_MULTIPART_TOTAL_PART_LIMIT+ environment variable.
216
-
217
- == History
218
-
219
- See <https://github.com/rack/rack/blob/master/HISTORY.md>.
220
-
221
- == Contact
222
-
223
- Please post bugs, suggestions and patches to
224
- the bug tracker at <https://github.com/rack/rack/issues>.
225
-
226
- Please post security related bugs and suggestions to the core team at
227
- <https://groups.google.com/group/rack-core> or rack-core@googlegroups.com. This
228
- list is not public. Due to wide usage of the library, it is strongly preferred
229
- that we manage timing in order to provide viable patches at the time of
230
- disclosure. Your assistance in this matter is greatly appreciated.
231
-
232
- Mailing list archives are available at
233
- <https://groups.google.com/group/rack-devel>.
234
-
235
- Git repository (send Git patches to the mailing list):
236
- * https://github.com/rack/rack
237
- * http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack-github.git
238
-
239
- You are also welcome to join the #rack channel on irc.freenode.net.
240
-
241
- == Thanks
242
-
243
- The Rack Core Team, consisting of
244
-
245
- * Leah Neukirchen (chneukirchen[https://github.com/chneukirchen])
246
- * James Tucker (raggi[https://github.com/raggi])
247
- * Josh Peek (josh[https://github.com/josh])
248
- * José Valim (josevalim[https://github.com/josevalim])
249
- * Michael Fellinger (manveru[https://github.com/manveru])
250
- * Aaron Patterson (tenderlove[https://github.com/tenderlove])
251
- * Santiago Pastorino (spastorino[https://github.com/spastorino])
252
- * Konstantin Haase (rkh[https://github.com/rkh])
253
-
254
- and the Rack Alumnis
255
-
256
- * Ryan Tomayko (rtomayko[https://github.com/rtomayko])
257
- * Scytrin dai Kinthra (scytrin[https://github.com/scytrin])
258
-
259
- would like to thank:
260
-
261
- * Adrian Madrid, for the LiteSpeed handler.
262
- * Christoffer Sawicki, for the first Rails adapter and Rack::Deflater.
263
- * Tim Fletcher, for the HTTP authentication code.
264
- * Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
265
- * Armin Ronacher, for the logo and racktools.
266
- * Alex Beregszaszi, Alexander Kahn, Anil Wadghule, Aredridel, Ben
267
- Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd, Tom Robinson,
268
- Phil Hagelberg, S. Brent Faulkner, Bosko Milekic, Daniel Rodríguez
269
- Troitiño, Genki Takiuchi, Geoffrey Grosenbach, Julien Sanchez, Kamal
270
- Fariz Mahyuddin, Masayoshi Takahashi, Patrick Aljordm, Mig, Kazuhiro
271
- Nishiyama, Jon Bardin, Konstantin Haase, Larry Siden, Matias
272
- Korhonen, Sam Ruby, Simon Chiang, Tim Connor, Timur Batyrshin, and
273
- Zach Brock for bug fixing and other improvements.
274
- * Eric Wong, Hongli Lai, Jeremy Kemper for their continuous support
275
- and API improvements.
276
- * Yehuda Katz and Carl Lerche for refactoring rackup.
277
- * Brian Candler, for Rack::ContentType.
278
- * Graham Batty, for improved handler loading.
279
- * Stephen Bannasch, for bug reports and documentation.
280
- * Gary Wright, for proposing a better Rack::Response interface.
281
- * Jonathan Buch, for improvements regarding Rack::Response.
282
- * Armin Röhrl, for tracking down bugs in the Cookie generator.
283
- * Alexander Kellett for testing the Gem and reviewing the announcement.
284
- * Marcus Rückert, for help with configuring and debugging lighttpd.
285
- * The WSGI team for the well-done and documented work they've done and
286
- Rack builds up on.
287
- * All bug reporters and patch contributors not mentioned above.
288
-
289
- == Copyright
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.
302
-
303
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
304
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
305
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
306
- THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
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.
309
-
310
- == Links
311
-
312
- Rack:: <https://rack.github.io/>
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>
data/Rakefile DELETED
@@ -1,116 +0,0 @@
1
- # Rakefile for Rack. -*-ruby-*-
2
-
3
- desc "Run all the tests"
4
- task :default => [:test]
5
-
6
- desc "Install gem dependencies"
7
- task :deps do
8
- require 'rubygems'
9
- spec = Gem::Specification.load('rack.gemspec')
10
- spec.dependencies.each do |dep|
11
- reqs = dep.requirements_list
12
- reqs = (["-v"] * reqs.size).zip(reqs).flatten
13
- # Use system over sh, because we want to ignore errors!
14
- system Gem.ruby, "-S", "gem", "install", '--conservative', dep.name, *reqs
15
- end
16
- end
17
-
18
- desc "Make an archive as .tar.gz"
19
- task :dist => %w[chmod ChangeLog SPEC rdoc] do
20
- sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
21
- sh "pax -waf #{release}.tar -s ':^:#{release}/:' SPEC ChangeLog doc rack.gemspec"
22
- sh "gzip -f -9 #{release}.tar"
23
- end
24
-
25
- desc "Make an official release"
26
- task :officialrelease do
27
- puts "Official build for #{release}..."
28
- sh "rm -rf stage"
29
- sh "git clone --shared . stage"
30
- sh "cd stage && rake officialrelease_really"
31
- sh "mv stage/#{release}.tar.gz stage/#{release}.gem ."
32
- end
33
-
34
- task :officialrelease_really => %w[SPEC dist gem] do
35
- sh "shasum #{release}.tar.gz #{release}.gem"
36
- end
37
-
38
- def release
39
- "rack-" + File.read('lib/rack.rb')[/RELEASE += +([\"\'])([\d][\w\.]+)\1/, 2]
40
- end
41
-
42
- desc "Make binaries executable"
43
- task :chmod do
44
- Dir["bin/*"].each { |binary| File.chmod(0755, binary) }
45
- Dir["test/cgi/test*"].each { |binary| File.chmod(0755, binary) }
46
- end
47
-
48
- desc "Generate a ChangeLog"
49
- task :changelog => %w[ChangeLog]
50
-
51
- file '.git/index'
52
- file "ChangeLog" => '.git/index' do
53
- File.open("ChangeLog", "w") { |out|
54
- log = `git log -z`
55
- log.force_encoding(Encoding::BINARY)
56
- log.split("\0").map { |chunk|
57
- author = chunk[/Author: (.*)/, 1].strip
58
- date = chunk[/Date: (.*)/, 1].strip
59
- desc, detail = $'.strip.split("\n", 2)
60
- detail ||= ""
61
- detail = detail.gsub(/.*darcs-hash:.*/, '')
62
- detail.rstrip!
63
- out.puts "#{date} #{author}"
64
- out.puts " * #{desc.strip}"
65
- out.puts detail unless detail.empty?
66
- out.puts
67
- }
68
- }
69
- end
70
-
71
- file 'lib/rack/lint.rb'
72
- desc "Generate Rack Specification"
73
- file "SPEC" => 'lib/rack/lint.rb' do
74
- File.open("SPEC", "wb") { |file|
75
- IO.foreach("lib/rack/lint.rb") { |line|
76
- if line =~ /## (.*)/
77
- file.puts $1
78
- end
79
- }
80
- }
81
- end
82
-
83
- desc "Run all the fast + platform agnostic tests"
84
- task :test => 'SPEC' do
85
- opts = ENV['TEST'] || ''
86
- specopts = ENV['TESTOPTS']
87
-
88
- sh "ruby -I./lib:./test -S minitest #{opts} #{specopts} test/gemloader.rb test/spec*.rb"
89
- end
90
-
91
- desc "Run all the tests we run on CI"
92
- task :ci => :test
93
-
94
- task :gem => ["SPEC"] do
95
- sh "gem build rack.gemspec"
96
- end
97
-
98
- task :doc => :rdoc
99
- desc "Generate RDoc documentation"
100
- task :rdoc => %w[ChangeLog SPEC] do
101
- sh(*%w{rdoc --line-numbers --main README.rdoc
102
- --title 'Rack\ Documentation' --charset utf-8 -U -o doc} +
103
- %w{README.rdoc KNOWN-ISSUES SPEC ChangeLog} +
104
- `git ls-files lib/\*\*/\*.rb`.strip.split)
105
- cp "contrib/rdoc.css", "doc/rdoc.css"
106
- end
107
-
108
- task :pushdoc => %w[rdoc] do
109
- sh "rsync -avz doc/ rack.rubyforge.org:/var/www/gforge-projects/rack/doc/"
110
- end
111
-
112
- task :pushsite => %w[pushdoc] do
113
- sh "cd site && git gc"
114
- sh "rsync -avz site/ rack.rubyforge.org:/var/www/gforge-projects/rack/"
115
- sh "cd site && git push"
116
- end
data/SPEC DELETED
@@ -1,263 +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 a 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 instance of Hash that includes
15
- CGI-like headers. The application is free to modify the
16
- 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 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>::
44
- When combined with <tt>SCRIPT_NAME</tt> and
45
- <tt>PATH_INFO</tt>, these variables can be
46
- used to complete the URL. Note, however,
47
- that <tt>HTTP_HOST</tt>, if present,
48
- should be used in preference to
49
- <tt>SERVER_NAME</tt> for reconstructing
50
- the request URL.
51
- <tt>SERVER_NAME</tt> and <tt>SERVER_PORT</tt>
52
- can never be empty strings, and so
53
- are always required.
54
- <tt>HTTP_</tt> Variables:: Variables corresponding to the
55
- client-supplied HTTP request
56
- headers (i.e., variables whose
57
- names begin with <tt>HTTP_</tt>). The
58
- presence or absence of these
59
- variables should correspond with
60
- the presence or absence of the
61
- appropriate HTTP header in the
62
- request. See
63
- {https://tools.ietf.org/html/rfc3875#section-4.1.18
64
- RFC3875 section 4.1.18} for
65
- specific behavior.
66
- In addition to this, the Rack environment must include these
67
- Rack-specific variables:
68
- <tt>rack.version</tt>:: The Array representing this version of Rack
69
- See Rack::VERSION, that corresponds to
70
- the version of this SPEC.
71
- <tt>rack.url_scheme</tt>:: +http+ or +https+, depending on the
72
- request URL.
73
- <tt>rack.input</tt>:: See below, the input stream.
74
- <tt>rack.errors</tt>:: See below, the error stream.
75
- <tt>rack.multithread</tt>:: true if the application object may be
76
- simultaneously invoked by another thread
77
- in the same process, false otherwise.
78
- <tt>rack.multiprocess</tt>:: true if an equivalent application object
79
- may be simultaneously invoked by another
80
- process, false otherwise.
81
- <tt>rack.run_once</tt>:: true if the server expects
82
- (but does not guarantee!) that the
83
- application will only be invoked this one
84
- time during the life of its containing
85
- process. Normally, this will only be true
86
- for a server based on CGI
87
- (or something similar).
88
- <tt>rack.hijack?</tt>:: present and true if the server supports
89
- connection hijacking. See below, hijacking.
90
- <tt>rack.hijack</tt>:: an object responding to #call that must be
91
- called at least once before using
92
- rack.hijack_io.
93
- It is recommended #call return rack.hijack_io
94
- as well as setting it in env if necessary.
95
- <tt>rack.hijack_io</tt>:: if rack.hijack? is true, and rack.hijack
96
- has received #call, this will contain
97
- an object resembling an IO. See hijacking.
98
- Additional environment specifications have approved to
99
- standardized middleware APIs. None of these are required to
100
- be implemented by the server.
101
- <tt>rack.session</tt>:: A hash like interface for storing request session data.
102
- The store must implement:
103
- store(key, value) (aliased as []=);
104
- fetch(key, default = nil) (aliased as []);
105
- delete(key);
106
- clear;
107
- <tt>rack.logger</tt>:: A common object interface for logging messages.
108
- The object must implement:
109
- info(message, &block)
110
- debug(message, &block)
111
- warn(message, &block)
112
- error(message, &block)
113
- fatal(message, &block)
114
- <tt>rack.multipart.buffer_size</tt>:: An Integer hint to the multipart parser as to what chunk size to use for reads and writes.
115
- <tt>rack.multipart.tempfile_factory</tt>:: An object responding to #call with two arguments, the filename and content_type given for the multipart form field, and returning an IO-like object that responds to #<< and optionally #rewind. This factory will be used to instantiate the tempfile for each multipart form file upload field, rather than the default class of Tempfile.
116
- The server or the application can store their own data in the
117
- environment, too. The keys must contain at least one dot,
118
- and should be prefixed uniquely. The prefix <tt>rack.</tt>
119
- is reserved for use with the Rack core distribution and other
120
- accepted specifications and must not be used otherwise.
121
- The environment must not contain the keys
122
- <tt>HTTP_CONTENT_TYPE</tt> or <tt>HTTP_CONTENT_LENGTH</tt>
123
- (use the versions without <tt>HTTP_</tt>).
124
- The CGI keys (named without a period) must have String values.
125
- There are the following restrictions:
126
- * <tt>rack.version</tt> must be an array of Integers.
127
- * <tt>rack.url_scheme</tt> must either be +http+ or +https+.
128
- * There must be a valid input stream in <tt>rack.input</tt>.
129
- * There must be a valid error stream in <tt>rack.errors</tt>.
130
- * There may be a valid hijack stream in <tt>rack.hijack_io</tt>
131
- * The <tt>REQUEST_METHOD</tt> must be a valid token.
132
- * The <tt>SCRIPT_NAME</tt>, if non-empty, must start with <tt>/</tt>
133
- * The <tt>PATH_INFO</tt>, if non-empty, must start with <tt>/</tt>
134
- * The <tt>CONTENT_LENGTH</tt>, if given, must consist of digits only.
135
- * One of <tt>SCRIPT_NAME</tt> or <tt>PATH_INFO</tt> must be
136
- set. <tt>PATH_INFO</tt> should be <tt>/</tt> if
137
- <tt>SCRIPT_NAME</tt> is empty.
138
- <tt>SCRIPT_NAME</tt> never should be <tt>/</tt>, but instead be empty.
139
- === The Input Stream
140
- The input stream is an IO-like object which contains the raw HTTP
141
- POST data.
142
- When applicable, its external encoding must be "ASCII-8BIT" and it
143
- must be opened in binary mode, for Ruby 1.9 compatibility.
144
- The input stream must respond to +gets+, +each+, +read+ and +rewind+.
145
- * +gets+ must be called without arguments and return a string,
146
- or +nil+ on EOF.
147
- * +read+ behaves like IO#read.
148
- Its signature is <tt>read([length, [buffer]])</tt>.
149
- If given, +length+ must be a non-negative Integer (>= 0) or +nil+,
150
- and +buffer+ must be a String and may not be nil.
151
- If +length+ is given and not nil, then this method reads at most
152
- +length+ bytes from the input stream.
153
- If +length+ is not given or nil, then this method reads
154
- all data until EOF.
155
- When EOF is reached, this method returns nil if +length+ is given
156
- and not nil, or "" if +length+ is not given or is nil.
157
- If +buffer+ is given, then the read data will be placed
158
- into +buffer+ instead of a newly created String object.
159
- * +each+ must be called without arguments and only yield Strings.
160
- * +rewind+ must be called without arguments. It rewinds the input
161
- stream back to the beginning. It must not raise Errno::ESPIPE:
162
- that is, it may not be a pipe or a socket. Therefore, handler
163
- developers must buffer the input data into some rewindable object
164
- if the underlying input stream is not rewindable.
165
- * +close+ must never be called on the input stream.
166
- === The Error Stream
167
- The error stream must respond to +puts+, +write+ and +flush+.
168
- * +puts+ must be called with a single argument that responds to +to_s+.
169
- * +write+ must be called with a single argument that is a String.
170
- * +flush+ must be called without arguments and must be called
171
- in order to make the error appear for sure.
172
- * +close+ must never be called on the error stream.
173
- === Hijacking
174
- ==== Request (before status)
175
- If rack.hijack? is true then rack.hijack must respond to #call.
176
- rack.hijack must return the io that will also be assigned (or is
177
- already present, in rack.hijack_io.
178
- rack.hijack_io must respond to:
179
- <tt>read, write, read_nonblock, write_nonblock, flush, close,
180
- close_read, close_write, closed?</tt>
181
- The semantics of these IO methods must be a best effort match to
182
- those of a normal ruby IO or Socket object, using standard
183
- arguments and raising standard exceptions. Servers are encouraged
184
- to simply pass on real IO objects, although it is recognized that
185
- this approach is not directly compatible with SPDY and HTTP 2.0.
186
- IO provided in rack.hijack_io should preference the
187
- IO::WaitReadable and IO::WaitWritable APIs wherever supported.
188
- There is a deliberate lack of full specification around
189
- rack.hijack_io, as semantics will change from server to server.
190
- Users are encouraged to utilize this API with a knowledge of their
191
- server choice, and servers may extend the functionality of
192
- hijack_io to provide additional features to users. The purpose of
193
- rack.hijack is for Rack to "get out of the way", as such, Rack only
194
- provides the minimum of specification and support.
195
- If rack.hijack? is false, then rack.hijack should not be set.
196
- If rack.hijack? is false, then rack.hijack_io should not be set.
197
- ==== Response (after headers)
198
- It is also possible to hijack a response after the status and headers
199
- have been sent.
200
- In order to do this, an application may set the special header
201
- <tt>rack.hijack</tt> to an object that responds to <tt>call</tt>
202
- accepting an argument that conforms to the <tt>rack.hijack_io</tt>
203
- protocol.
204
- After the headers have been sent, and this hijack callback has been
205
- called, the application is now responsible for the remaining lifecycle
206
- of the IO. The application is also responsible for maintaining HTTP
207
- semantics. Of specific note, in almost all cases in the current SPEC,
208
- applications will have wanted to specify the header Connection:close in
209
- HTTP/1.1, and not Connection:keep-alive, as there is no protocol for
210
- returning hijacked sockets to the web server. For that purpose, use the
211
- body streaming API instead (progressively yielding strings via each).
212
- Servers must ignore the <tt>body</tt> part of the response tuple when
213
- the <tt>rack.hijack</tt> response API is in use.
214
- The special response header <tt>rack.hijack</tt> must only be set
215
- if the request env has <tt>rack.hijack?</tt> <tt>true</tt>.
216
- ==== Conventions
217
- * Middleware should not use hijack unless it is handling the whole
218
- response.
219
- * Middleware may wrap the IO object for the response pattern.
220
- * Middleware should not wrap the IO object for the request pattern. The
221
- request pattern is intended to provide the hijacker with "raw tcp".
222
- == The Response
223
- === The Status
224
- This is an HTTP status. When parsed as integer (+to_i+), it must be
225
- greater than or equal to 100.
226
- === The Headers
227
- The header must respond to +each+, and yield values of key and value.
228
- Special headers starting "rack." are for communicating with the
229
- server, and must not be sent back to the client.
230
- The header keys must be Strings.
231
- The header must not contain a +Status+ key.
232
- The header must conform to RFC7230 token specification, i.e. cannot
233
- contain non-printable ASCII, DQUOTE or "(),/:;<=>?@[\]{}".
234
- The values of the header must be Strings,
235
- consisting of lines (for multiple header values, e.g. multiple
236
- <tt>Set-Cookie</tt> values) separated by "\\n".
237
- The lines must not contain characters below 037.
238
- === The Content-Type
239
- There must not be a <tt>Content-Type</tt>, when the +Status+ is 1xx,
240
- 204 or 304.
241
- === The Content-Length
242
- There must not be a <tt>Content-Length</tt> header when the
243
- +Status+ is 1xx, 204 or 304.
244
- === The Body
245
- The Body must respond to +each+
246
- and must only yield String values.
247
- The Body itself should not be an instance of String, as this will
248
- break in Ruby 1.9.
249
- If the Body responds to +close+, it will be called after iteration. If
250
- the body is replaced by a middleware after action, the original body
251
- must be closed first, if it responds to close.
252
- If the Body responds to +to_path+, it must return a String
253
- identifying the location of a file whose contents are identical
254
- to that produced by calling +each+; this may be used by the
255
- server as an alternative, possibly more efficient way to
256
- transport the response.
257
- The Body commonly is an Array of Strings, the application
258
- instance itself, or a File-like object.
259
- == Thanks
260
- Some parts of this specification are adopted from PEP333: Python
261
- Web Server Gateway Interface
262
- v1.0 (http://www.python.org/dev/peps/pep-0333/). I'd like to thank
263
- everyone involved in that effort.