rack 0.4.0 → 0.9.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 (59) hide show
  1. data/RDOX +61 -3
  2. data/README +52 -37
  3. data/Rakefile +9 -0
  4. data/SPEC +6 -3
  5. data/bin/rackup +0 -0
  6. data/lib/rack.rb +7 -2
  7. data/lib/rack/adapter/camping.rb +1 -1
  8. data/lib/rack/auth/openid.rb +4 -3
  9. data/lib/rack/builder.rb +12 -1
  10. data/lib/rack/conditionalget.rb +43 -0
  11. data/lib/rack/content_length.rb +25 -0
  12. data/lib/rack/deflater.rb +29 -5
  13. data/lib/rack/directory.rb +82 -91
  14. data/lib/rack/file.rb +45 -76
  15. data/lib/rack/handler.rb +4 -0
  16. data/lib/rack/handler/evented_mongrel.rb +1 -1
  17. data/lib/rack/handler/fastcgi.rb +2 -0
  18. data/lib/rack/handler/mongrel.rb +6 -2
  19. data/lib/rack/handler/swiftiplied_mongrel.rb +8 -0
  20. data/lib/rack/handler/thin.rb +15 -0
  21. data/lib/rack/handler/webrick.rb +8 -4
  22. data/lib/rack/head.rb +19 -0
  23. data/lib/rack/lint.rb +74 -10
  24. data/lib/rack/lobster.rb +13 -13
  25. data/lib/rack/methodoverride.rb +27 -0
  26. data/lib/rack/mime.rb +204 -0
  27. data/lib/rack/request.rb +10 -1
  28. data/lib/rack/response.rb +7 -2
  29. data/lib/rack/session/abstract/id.rb +14 -1
  30. data/lib/rack/session/cookie.rb +19 -1
  31. data/lib/rack/session/memcache.rb +1 -1
  32. data/lib/rack/session/pool.rb +1 -1
  33. data/lib/rack/showexceptions.rb +5 -1
  34. data/lib/rack/showstatus.rb +3 -2
  35. data/lib/rack/urlmap.rb +1 -1
  36. data/lib/rack/utils.rb +42 -13
  37. data/test/cgi/lighttpd.conf +1 -1
  38. data/test/cgi/test +0 -0
  39. data/test/cgi/test.fcgi +0 -0
  40. data/test/cgi/test.ru +0 -0
  41. data/test/spec_rack_builder.rb +34 -0
  42. data/test/spec_rack_conditionalget.rb +41 -0
  43. data/test/spec_rack_content_length.rb +43 -0
  44. data/test/spec_rack_deflater.rb +49 -14
  45. data/test/spec_rack_file.rb +7 -0
  46. data/test/spec_rack_handler.rb +3 -3
  47. data/test/spec_rack_head.rb +30 -0
  48. data/test/spec_rack_lint.rb +79 -2
  49. data/test/spec_rack_methodoverride.rb +60 -0
  50. data/test/spec_rack_mock.rb +1 -1
  51. data/test/spec_rack_mongrel.rb +20 -1
  52. data/test/spec_rack_request.rb +46 -1
  53. data/test/spec_rack_response.rb +10 -3
  54. data/test/spec_rack_session_cookie.rb +33 -0
  55. data/test/spec_rack_thin.rb +90 -0
  56. data/test/spec_rack_utils.rb +20 -18
  57. data/test/spec_rack_webrick.rb +17 -0
  58. data/test/testrequest.rb +12 -0
  59. metadata +91 -5
data/RDOX CHANGED
@@ -29,6 +29,8 @@
29
29
  * chains apps by default
30
30
  * has implicit #to_app
31
31
  * supports blocks on use
32
+ * has explicit #to_app
33
+ * apps are initialized once
32
34
 
33
35
  == Rack::Adapter::Camping
34
36
  * works with GET
@@ -55,12 +57,28 @@
55
57
  * should log to rack.errors by default
56
58
  * should log to anything with <<
57
59
 
60
+ == Rack::ConditionalGet
61
+ * should set a 304 status and truncate body when If-Modified-Since hits
62
+ * should set a 304 status and truncate body when If-None-Match hits
63
+ * should not affect non-GET/HEAD requests
64
+
65
+ == Rack::ContentLength
66
+ * sets Content-Length on String bodies if none is set
67
+ * sets Content-Length on Array bodies if none is set
68
+ * does not set Content-Length on variable length bodies
69
+ * does not change Content-Length if it is already set
70
+ * does not set Content-Length on 304 responses
71
+ * does not set Content-Length when Transfer-Encoding is chunked
72
+
58
73
  == Rack::Deflater
59
74
  * should be able to deflate bodies that respond to each
60
75
  * should be able to deflate String bodies
61
76
  * should be able to gzip bodies that respond to each
62
77
  * should be able to fallback to no deflation
78
+ * should be able to skip when there is no response entity body
63
79
  * should handle the lack of an acceptable encoding
80
+ * should handle gzip response with Last-Modified header
81
+ * should do nothing when no-transform Cache-Control directive present
64
82
 
65
83
  == Rack::Directory
66
84
  * serves directory indices
@@ -86,12 +104,18 @@
86
104
  * serves files with URL encoded filenames
87
105
  * does not allow directory traversal
88
106
  * 404s if it can't find the file
107
+ * detects SystemCallErrors
89
108
 
90
109
  == Rack::Handler
91
110
  * has registered default handlers
92
111
  * should get unregistered handler by name
93
112
  * should register custom handler
94
113
 
114
+ == Rack::Head
115
+ * response (empty)
116
+ * passes GET, POST, PUT, DELETE, OPTIONS, TRACE requests
117
+ * removes body from HEAD requests
118
+
95
119
  == Rack::Lint
96
120
  * passes valid request
97
121
  * notices fatal errors
@@ -101,9 +125,15 @@
101
125
  * notices status errors
102
126
  * notices header errors
103
127
  * notices content-type errors
128
+ * notices content-length errors
104
129
  * notices body errors
105
130
  * notices input handling errors
106
131
  * notices error handling errors
132
+ * notices HEAD errors
133
+
134
+ == Rack::Lint::InputWrapper
135
+ * delegates :size to underlying IO object
136
+ * delegates :rewind to underlying IO object
107
137
 
108
138
  == Rack::Lobster::LambdaLobster
109
139
  * should be a single lambda
@@ -115,6 +145,14 @@
115
145
  * should be flippable
116
146
  * should provide crashing for testing purposes
117
147
 
148
+ == Rack::MethodOverride
149
+ * should not affect GET requests
150
+ * _method parameter should modify REQUEST_METHOD for POST requests
151
+ * X-HTTP-Method-Override header should modify REQUEST_METHOD for POST requests
152
+ * should not modify REQUEST_METHOD if the method is unknown
153
+ * should not modify REQUEST_METHOD when _method is nil
154
+ * should store the original REQUEST_METHOD prior to overriding
155
+
118
156
  == Rack::MockRequest
119
157
  * should return a MockResponse
120
158
  * should be able to only return the environment
@@ -143,6 +181,7 @@
143
181
  * should provide a .run that maps a hash
144
182
  * should provide a .run that maps a urlmap
145
183
  * should provide a .run that maps a urlmap restricting by host
184
+ * should stream #each part of the response
146
185
 
147
186
  == Rack::Recursive
148
187
  * should allow for subrequests
@@ -156,6 +195,8 @@
156
195
  * can parse POST data
157
196
  * can parse POST data with explicit content type
158
197
  * does not parse POST data when media type is not form-data
198
+ * rewinds input after parsing POST data
199
+ * does not rewind unwindable CGI input
159
200
  * can get value by key from params with #[]
160
201
  * can set value to key on params with #[]=
161
202
  * values_at answers values by keys in order given
@@ -175,6 +216,7 @@
175
216
  * should work around buggy 1.8.* Tempfile equality
176
217
  * does conform to the Rack spec
177
218
  * should parse Accept-Encoding correctly
219
+ * should provide ip information
178
220
 
179
221
  == Rack::Response
180
222
  * has sensible default values
@@ -182,6 +224,7 @@
182
224
  * can set and read headers
183
225
  * can set cookies
184
226
  * formats the Cookie expiration date accordingly to RFC 2109
227
+ * can set secure cookies
185
228
  * can delete cookies
186
229
  * has a useful constructor
187
230
  * has a constructor that can take a block
@@ -195,6 +238,9 @@
195
238
  * loads from a cookie
196
239
  * survives broken cookies
197
240
  * barks on too big cookies
241
+ * creates a new cookie with integrity hash
242
+ * loads from a cookie wih integrity hash
243
+ * ignores tampered with session cookies
198
244
 
199
245
  == Rack::Session::Memcache
200
246
  * startup (empty)
@@ -228,6 +274,15 @@
228
274
  * 404s if url root is known but it can't find the file
229
275
  * calls down the chain if url root is not known
230
276
 
277
+ == Rack::Handler::Thin
278
+ * should respond
279
+ * should be a Thin
280
+ * should have rack headers
281
+ * should have CGI headers on GET
282
+ * should have CGI headers on POST
283
+ * should support HTTP auth
284
+ * should set status
285
+
231
286
  == Rack::URLMap
232
287
  * dispatches paths correctly
233
288
  * dispatches hosts correctly
@@ -242,8 +297,10 @@
242
297
  * should figure out which encodings are acceptable
243
298
 
244
299
  == Rack::Utils::HeaderHash
245
- * should capitalize on all accesses
246
- * should capitalize correctly
300
+ * should retain header case
301
+ * should check existence of keys case insensitively
302
+ * should merge case-insensitively
303
+ * should overwrite case insensitively and assume the new key's case
247
304
  * should be converted to real Hash
248
305
 
249
306
  == Rack::Utils::Context
@@ -260,6 +317,7 @@
260
317
  * should have CGI headers on POST
261
318
  * should support HTTP auth
262
319
  * should set status
320
+ * should correctly set cookies
263
321
  * should provide a .run
264
322
 
265
- 197 specifications, 3 empty (886 requirements), 0 failures
323
+ 243 specifications, 4 empty (1008 requirements), 0 failures
data/README CHANGED
@@ -9,38 +9,23 @@ middleware) into a single method call.
9
9
  The exact details of this are described in the Rack specification,
10
10
  which all Rack applications should conform to.
11
11
 
12
- == Future specification changes
13
-
14
- PLEASE NOTE: In versions of Rack LATER than 0.4, the following
15
- changes will be commited to the Rack specification:
16
-
17
- * 1xx, 204 and 304 status codes MUST not contain a Content-Type.
18
- * A valid Content-Length header MUST be provided for non 1xx, 204 and 304
19
- responses with a Transfer-Encoding of "identity" (default).
20
- The Content-Length MUST be the same as the sum of the byte-sizes of
21
- the chunks.
22
- * The REQUEST_METHOD may be any HTTP token.
23
-
24
- Internal Rack modules have been updated to follow this behavior, but
25
- the Rack 0.4 Lint does NOT check it yet for compatibility reasons.
26
- Please update your libraries accordingly.
27
-
28
12
  == Supported web servers
29
13
 
30
14
  The included *handlers* connect all kinds of web servers to Rack:
31
15
  * Mongrel
32
16
  * EventedMongrel
17
+ * SwiftipliedMongrel
33
18
  * WEBrick
34
19
  * FCGI
35
20
  * CGI
36
21
  * SCGI
37
22
  * LiteSpeed
23
+ * Thin
38
24
 
39
25
  These web servers include Rack handlers in their distributions:
40
26
  * Ebb
41
27
  * Fuzed
42
28
  * Phusion Passenger (which is mod_rack for Apache)
43
- * Thin
44
29
 
45
30
  Any valid Rack app will run the same on all these handlers, without
46
31
  changing anything.
@@ -58,13 +43,12 @@ These frameworks include Rack adapters in their distributions:
58
43
  * Merb
59
44
  * Racktools::SimpleApplication
60
45
  * Ramaze
46
+ * Ruby on Rails
61
47
  * Sinatra
48
+ * Sin
62
49
  * Vintage
63
50
  * Waves
64
51
 
65
- Ruby on Rails can be run with the adapter included with Thin, which
66
- will be merged into a later Rack version.
67
-
68
52
  Current links to these projects can be found at
69
53
  http://ramaze.net/#other-frameworks
70
54
 
@@ -96,6 +80,14 @@ over:
96
80
  * Rack::MockRequest and Rack::MockResponse for efficient and quick
97
81
  testing of Rack application without real HTTP round-trips.
98
82
 
83
+ == rack-contrib
84
+
85
+ The plethora of useful middleware created the need for a project that
86
+ collects fresh Rack middleware. rack-contrib includes a variety of
87
+ add-on components for Rack and it is easy to contribute new modules.
88
+
89
+ * http://github.com/rack/rack-contrib
90
+
99
91
  == rackup
100
92
 
101
93
  rackup is a useful tool for running Rack applications, which uses the
@@ -129,7 +121,7 @@ A Gem of Rack is available. You can install it with:
129
121
  I also provide a local mirror of the gems (and development snapshots)
130
122
  at my site:
131
123
 
132
- gem install rack --source http://chneukirchen.org/releases/gems
124
+ gem install rack --source http://chneukirchen.org/releases/gems/
133
125
 
134
126
  == Running the tests
135
127
 
@@ -204,7 +196,7 @@ run on port 11211) and memcache-client installed.
204
196
  * HTTP status 201 can contain a Content-Type and a body now.
205
197
  * Many bugfixes, especially related to Cookie handling.
206
198
 
207
- * August 21th, 2008: Fourth public release 0.4.
199
+ * August 21st, 2008: Fourth public release 0.4.
208
200
  * New middleware, Rack::Deflater, by Christoffer Sawicki.
209
201
  * OpenID authentication now needs ruby-openid 2.
210
202
  * New Memcache sessions, by blink.
@@ -216,37 +208,63 @@ run on port 11211) and memcache-client installed.
216
208
  * Improved tests.
217
209
  * Rack moved to Git.
218
210
 
211
+ * January 6th, 2009: Fifth public release 0.9.
212
+ * Rack is now managed by the Rack Core Team.
213
+ * Rack::Lint is stricter and follows the HTTP RFCs more closely.
214
+ * Added ConditionalGet middleware.
215
+ * Added ContentLength middleware.
216
+ * Added Deflater middleware.
217
+ * Added Head middleware.
218
+ * Added MethodOverride middleware.
219
+ * Rack::Mime now provides popular MIME-types and their extension.
220
+ * Mongrel Header now streams.
221
+ * Added Thin handler.
222
+ * Official support for swiftiplied Mongrel.
223
+ * Secure cookies.
224
+ * Made HeaderHash case-preserving.
225
+ * Many bugfixes and small improvements.
226
+
219
227
  == Contact
220
228
 
221
229
  Please mail bugs, suggestions and patches to
222
230
  <mailto:rack-devel@googlegroups.com>.
223
231
 
224
232
  Mailing list archives are available at
225
- <http://groups.google.com/group/rack-devel>
233
+ <http://groups.google.com/group/rack-devel>.
234
+
235
+ There is a bug tracker at <http://rack.lighthouseapp.com/>.
226
236
 
227
- Git repository (branches rebased on master are most welcome):
228
- * http://github.com/chneukirchen/rack
237
+ Git repository (patches rebased on master are most welcome):
238
+ * http://github.com/rack/rack
229
239
  * http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack.git
230
240
 
231
241
  You are also welcome to join the #rack channel on irc.freenode.net.
232
242
 
233
- == Thanks to
243
+ == Thanks
244
+
245
+ The Rack Core Team, consisting of
246
+
247
+ * Christian Neukirchen (chneukirchen)
248
+ * James Tucker (raggi)
249
+ * Josh Peek (josh)
250
+ * Michael Fellinger (manveru)
251
+ * Ryan Tomayko (rtomayko)
252
+ * Scytrin dai Kinthra (scytrin)
253
+
254
+ would like to thank:
234
255
 
235
- * blink for the Pool sessions, Memcache sessions, OpenID support, many
236
- tweaks, patches and bugreports.
237
- * Michael Fellinger, for the helpful discussion, bugfixes and a better
238
- Rack::Request interface.
239
256
  * Adrian Madrid, for the LiteSpeed handler.
240
257
  * Christoffer Sawicki, for the first Rails adapter and Rack::Deflater.
241
258
  * Tim Fletcher, for the HTTP authentication code.
242
259
  * Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
243
260
  * Armin Ronacher, for the logo and racktools.
244
- * Aredridel, for bug fixing.
261
+ * Aredridel, Ben Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd, and
262
+ Phil Hagelberg for bug fixing and other improvements.
245
263
  * Stephen Bannasch, for bug reports and documentation.
246
264
  * Gary Wright, for proposing a better Rack::Response interface.
247
265
  * Jonathan Buch, for improvements regarding Rack::Response.
248
266
  * Armin Röhrl, for tracking down bugs in the Cookie generator.
249
- * Alexander Kellett for testing the Gem and reviewing the announce.
267
+ * Alexander Kellett for testing the Gem and reviewing the announcement.
250
268
  * Marcus Rückert, for help with configuring and debugging lighttpd.
251
269
  * The WSGI team for the well-done and documented work they've done and
252
270
  Rack builds up on.
@@ -254,7 +272,7 @@ You are also welcome to join the #rack channel on irc.freenode.net.
254
272
 
255
273
  == Copyright
256
274
 
257
- Copyright (C) 2007, 2008 Christian Neukirchen <http://purl.org/net/chneukirchen>
275
+ Copyright (C) 2007, 2008, 2009 Christian Neukirchen <http://purl.org/net/chneukirchen>
258
276
 
259
277
  Permission is hereby granted, free of charge, to any person obtaining a copy
260
278
  of this software and associated documentation files (the "Software"), to
@@ -277,11 +295,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
277
295
 
278
296
  Rack:: <http://rack.rubyforge.org/>
279
297
  Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
298
+ Official Rack repositories:: <http://github.com/rack>
280
299
  rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
281
300
 
282
- Camping:: <http://camping.rubyforge.org/>
283
- Ramaze:: <http://ramaze.rubyforge.org/>
284
- Maveric:: <http://maveric.rubyforge.org/>
285
-
286
301
  Christian Neukirchen:: <http://chneukirchen.org/>
287
302
 
data/Rakefile CHANGED
@@ -133,6 +133,15 @@ Also see http://rack.rubyforge.org.
133
133
  s.email = 'chneukirchen@gmail.com'
134
134
  s.homepage = 'http://rack.rubyforge.org'
135
135
  s.rubyforge_project = 'rack'
136
+
137
+ s.add_development_dependency 'test-spec'
138
+
139
+ s.add_development_dependency 'camping'
140
+ s.add_development_dependency 'fcgi'
141
+ s.add_development_dependency 'memcache-client'
142
+ s.add_development_dependency 'mongrel'
143
+ s.add_development_dependency 'ruby-openid', '~> 2.0.0'
144
+ s.add_development_dependency 'thin'
136
145
  end
137
146
 
138
147
  Rake::GemPackageTask.new(spec) do |p|
data/SPEC CHANGED
@@ -71,8 +71,7 @@ There are the following restrictions:
71
71
  * <tt>rack.url_scheme</tt> must either be +http+ or +https+.
72
72
  * There must be a valid input stream in <tt>rack.input</tt>.
73
73
  * There must be a valid error stream in <tt>rack.errors</tt>.
74
- * The <tt>REQUEST_METHOD</tt> must be one of +GET+, +POST+, +PUT+,
75
- +DELETE+, +HEAD+, +OPTIONS+, +TRACE+.
74
+ * The <tt>REQUEST_METHOD</tt> must be a valid token.
76
75
  * The <tt>SCRIPT_NAME</tt>, if non-empty, must start with <tt>/</tt>
77
76
  * The <tt>PATH_INFO</tt>, if non-empty, must start with <tt>/</tt>
78
77
  * The <tt>CONTENT_LENGTH</tt>, if given, must consist of digits only.
@@ -111,7 +110,11 @@ The values passed on #each must be Strings
111
110
  and not contain characters below 037.
112
111
  === The Content-Type
113
112
  There must be a <tt>Content-Type</tt>, except when the
114
- +Status+ is 204 or 304, in which case there must be none
113
+ +Status+ is 1xx, 204 or 304, in which case there must be none
114
+ given.
115
+ === The Content-Length
116
+ There must be a <tt>Content-Length</tt>, except when the
117
+ +Status+ is 1xx, 204 or 304, in which case there must be none
115
118
  given.
116
119
  === The Body
117
120
  The Body must respond to #each
data/bin/rackup CHANGED
File without changes
data/lib/rack.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2007, 2008 Christian Neukirchen <purl.org/net/chneukirchen>
1
+ # Copyright (C) 2007, 2008, 2009 Christian Neukirchen <purl.org/net/chneukirchen>
2
2
  #
3
3
  # Rack is freely distributable under the terms of an MIT-style license.
4
4
  # See COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -23,18 +23,23 @@ module Rack
23
23
 
24
24
  # Return the Rack release as a dotted string.
25
25
  def self.release
26
- "0.4"
26
+ "0.9"
27
27
  end
28
28
 
29
29
  autoload :Builder, "rack/builder"
30
30
  autoload :Cascade, "rack/cascade"
31
31
  autoload :CommonLogger, "rack/commonlogger"
32
+ autoload :ConditionalGet, "rack/conditionalget"
33
+ autoload :ContentLength, "rack/content_length"
32
34
  autoload :File, "rack/file"
33
35
  autoload :Deflater, "rack/deflater"
34
36
  autoload :Directory, "rack/directory"
35
37
  autoload :ForwardRequest, "rack/recursive"
36
38
  autoload :Handler, "rack/handler"
39
+ autoload :Head, "rack/head"
37
40
  autoload :Lint, "rack/lint"
41
+ autoload :MethodOverride, "rack/methodoverride"
42
+ autoload :Mime, "rack/mime"
38
43
  autoload :Recursive, "rack/recursive"
39
44
  autoload :Reloader, "rack/reloader"
40
45
  autoload :ShowExceptions, "rack/showexceptions"
@@ -15,7 +15,7 @@ module Rack
15
15
  h[k] = v.to_s
16
16
  end
17
17
  end
18
- [controller.status, controller.headers, controller.body]
18
+ [controller.status, controller.headers, [controller.body.to_s]]
19
19
  end
20
20
  end
21
21
  end
@@ -343,7 +343,7 @@ module Rack
343
343
  session['authenticated'] = false
344
344
  req.env['rack.errors'].puts oid.message
345
345
 
346
- goto = @options[:login_fail] if @option.key? :login_fail
346
+ goto = @options[:login_fail] if @options.key? :login_fail
347
347
  body << "Authentication unsuccessful.\n"
348
348
  when ::OpenID::Consumer::SUCCESS
349
349
  session.clear
@@ -367,7 +367,7 @@ module Rack
367
367
  session.clear
368
368
  session['authenticated'] = false
369
369
 
370
- goto = @options[:login_fail] if @option.key? :login_fail
370
+ goto = @options[:login_fail] if @options.key? :login_fail
371
371
  body << "Authentication cancelled.\n"
372
372
  when ::OpenID::Consumer::SETUP_NEEDED
373
373
  session[:setup_needed] = true
@@ -402,7 +402,8 @@ module Rack
402
402
  def add_extension ext, *args
403
403
  if not ext.is_a? Module
404
404
  raise TypeError, "#{ext.inspect} is not a module"
405
- elsif not (m = %w'Request Response NS_URI' - ext.constants).empty?
405
+ elsif !(m = %w'Request Response NS_URI' -
406
+ ext.constants.map{ |c| c.to_s }).empty?
406
407
  raise ArgumentError, "#{ext.inspect} missing #{m*', '}"
407
408
  end
408
409