rack 0.3.0 → 0.4.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 (50) hide show
  1. data/AUTHORS +1 -0
  2. data/RDOX +61 -3
  3. data/README +94 -9
  4. data/Rakefile +36 -32
  5. data/SPEC +1 -7
  6. data/bin/rackup +31 -13
  7. data/lib/rack.rb +8 -19
  8. data/lib/rack/auth/digest/params.rb +2 -2
  9. data/lib/rack/auth/openid.rb +406 -80
  10. data/lib/rack/builder.rb +1 -1
  11. data/lib/rack/cascade.rb +10 -0
  12. data/lib/rack/commonlogger.rb +6 -1
  13. data/lib/rack/deflater.rb +63 -0
  14. data/lib/rack/directory.rb +158 -0
  15. data/lib/rack/file.rb +11 -5
  16. data/lib/rack/handler.rb +44 -0
  17. data/lib/rack/handler/evented_mongrel.rb +8 -0
  18. data/lib/rack/handler/fastcgi.rb +1 -0
  19. data/lib/rack/handler/mongrel.rb +21 -1
  20. data/lib/rack/lint.rb +20 -13
  21. data/lib/rack/mock.rb +1 -0
  22. data/lib/rack/request.rb +69 -2
  23. data/lib/rack/session/abstract/id.rb +140 -0
  24. data/lib/rack/session/memcache.rb +97 -0
  25. data/lib/rack/session/pool.rb +50 -59
  26. data/lib/rack/showstatus.rb +3 -1
  27. data/lib/rack/urlmap.rb +12 -12
  28. data/lib/rack/utils.rb +88 -9
  29. data/test/cgi/lighttpd.conf +1 -1
  30. data/test/cgi/test.fcgi +1 -2
  31. data/test/cgi/test.ru +2 -2
  32. data/test/spec_rack_auth_openid.rb +137 -0
  33. data/test/spec_rack_camping.rb +37 -33
  34. data/test/spec_rack_cascade.rb +15 -0
  35. data/test/spec_rack_cgi.rb +4 -3
  36. data/test/spec_rack_deflater.rb +70 -0
  37. data/test/spec_rack_directory.rb +56 -0
  38. data/test/spec_rack_fastcgi.rb +4 -3
  39. data/test/spec_rack_file.rb +11 -1
  40. data/test/spec_rack_handler.rb +24 -0
  41. data/test/spec_rack_lint.rb +19 -33
  42. data/test/spec_rack_mongrel.rb +71 -0
  43. data/test/spec_rack_request.rb +91 -1
  44. data/test/spec_rack_session_memcache.rb +132 -0
  45. data/test/spec_rack_session_pool.rb +48 -1
  46. data/test/spec_rack_showstatus.rb +5 -4
  47. data/test/spec_rack_urlmap.rb +60 -25
  48. data/test/spec_rack_utils.rb +118 -1
  49. data/test/testrequest.rb +3 -1
  50. metadata +67 -44
data/AUTHORS CHANGED
@@ -2,6 +2,7 @@
2
2
  * HTTP authentication: Tim Fletcher <twoggle@gmail.com>
3
3
  * Cookie sessions, Static handler: Luc Heinrich <luc@honk-honk.com>
4
4
  * Pool sessions, OpenID authentication: blink <blinketje@gmail.com>
5
+ * Rack::Deflater: Christoffer Sawicki <christoffer.sawicki@gmail.com>
5
6
  * LiteSpeed handler: Adrian Madrid
6
7
  * SCGI handler: Jeremy Evans
7
8
  * Official Logo: Armin Ronacher
data/RDOX CHANGED
@@ -16,6 +16,15 @@
16
16
  * should return 400 Bad Request if incorrect uri given
17
17
  * should return 400 Bad Request if different auth scheme used
18
18
 
19
+ == Rack::Auth::OpenID
20
+ * realm uri should be absolute and have a path
21
+ * uri options should be absolute
22
+ * return_to should be absolute and be under the realm
23
+ * extensions should be a module
24
+ * extensions should have required constants defined
25
+ * extensions should have Request and Response defined and inherit from OpenID::Extension
26
+ * extensions should have NS_URI defined and be a string of an absolute http uri
27
+
19
28
  == Rack::Builder
20
29
  * chains apps by default
21
30
  * has implicit #to_app
@@ -29,6 +38,7 @@
29
38
  * should dispatch onward on 404 by default
30
39
  * should dispatch onward on whatever is passed
31
40
  * should fail if empty
41
+ * should append new app
32
42
 
33
43
  == Rack::Handler::CGI
34
44
  * startup (empty)
@@ -45,6 +55,20 @@
45
55
  * should log to rack.errors by default
46
56
  * should log to anything with <<
47
57
 
58
+ == Rack::Deflater
59
+ * should be able to deflate bodies that respond to each
60
+ * should be able to deflate String bodies
61
+ * should be able to gzip bodies that respond to each
62
+ * should be able to fallback to no deflation
63
+ * should handle the lack of an acceptable encoding
64
+
65
+ == Rack::Directory
66
+ * serves directory indices
67
+ * passes to app if file found
68
+ * serves uri with URL encoded filenames
69
+ * does not allow directory traversal
70
+ * 404s if it can't find the file
71
+
48
72
  == Rack::Handler::FastCGI
49
73
  * startup (empty)
50
74
  * should respond
@@ -58,10 +82,16 @@
58
82
 
59
83
  == Rack::File
60
84
  * serves files
85
+ * sets Last-Modified header
61
86
  * serves files with URL encoded filenames
62
87
  * does not allow directory traversal
63
88
  * 404s if it can't find the file
64
89
 
90
+ == Rack::Handler
91
+ * has registered default handlers
92
+ * should get unregistered handler by name
93
+ * should register custom handler
94
+
65
95
  == Rack::Lint
66
96
  * passes valid request
67
97
  * notices fatal errors
@@ -110,6 +140,9 @@
110
140
  * should support HTTP auth
111
141
  * should set status
112
142
  * should provide a .run
143
+ * should provide a .run that maps a hash
144
+ * should provide a .run that maps a urlmap
145
+ * should provide a .run that maps a urlmap restricting by host
113
146
 
114
147
  == Rack::Recursive
115
148
  * should allow for subrequests
@@ -121,6 +154,8 @@
121
154
  * can figure out the correct host
122
155
  * can parse the query string
123
156
  * can parse POST data
157
+ * can parse POST data with explicit content type
158
+ * does not parse POST data when media type is not form-data
124
159
  * can get value by key from params with #[]
125
160
  * can set value to key on params with #[]=
126
161
  * values_at answers values by keys in order given
@@ -133,10 +168,13 @@
133
168
  * provides the original env
134
169
  * can restore the URL
135
170
  * can restore the full path
171
+ * can handle multiple media type parameters
136
172
  * can parse multipart form data
137
173
  * can parse big multipart form data
138
174
  * can detect invalid multipart form data
175
+ * should work around buggy 1.8.* Tempfile equality
139
176
  * does conform to the Rack spec
177
+ * should parse Accept-Encoding correctly
140
178
 
141
179
  == Rack::Response
142
180
  * has sensible default values
@@ -158,10 +196,22 @@
158
196
  * survives broken cookies
159
197
  * barks on too big cookies
160
198
 
199
+ == Rack::Session::Memcache
200
+ * startup (empty)
201
+ * faults on no connection
202
+ * creates a new cookie
203
+ * determines session from a cookie
204
+ * survives broken cookies
205
+ * maintains freshness
206
+ * multithread: should cleanly merge sessions
207
+ * shutdown
208
+
161
209
  == Rack::Session::Pool
162
210
  * creates a new cookie
163
- * loads from a cookie
211
+ * determines session from a cookie
164
212
  * survives broken cookies
213
+ * maintains freshness
214
+ * multithread: should merge sessions
165
215
 
166
216
  == Rack::ShowExceptions
167
217
  * catches exceptions
@@ -187,13 +237,21 @@
187
237
  == Rack::Utils
188
238
  * should escape correctly
189
239
  * should unescape correctly
190
- * should parse queries correctly
240
+ * should parse query strings correctly
241
+ * should build query strings correctly
242
+ * should figure out which encodings are acceptable
191
243
 
192
244
  == Rack::Utils::HeaderHash
193
245
  * should capitalize on all accesses
194
246
  * should capitalize correctly
195
247
  * should be converted to real Hash
196
248
 
249
+ == Rack::Utils::Context
250
+ * should perform checks on both arguments
251
+ * should set context correctly
252
+ * should alter app on recontexting
253
+ * should run different apps
254
+
197
255
  == Rack::Handler::WEBrick
198
256
  * should respond
199
257
  * should be a WEBrick
@@ -204,4 +262,4 @@
204
262
  * should set status
205
263
  * should provide a .run
206
264
 
207
- 151 specifications, 2 empty (598 requirements), 0 failures
265
+ 197 specifications, 3 empty (886 requirements), 0 failures
data/README CHANGED
@@ -9,11 +9,27 @@ 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
+
12
28
  == Supported web servers
13
29
 
14
30
  The included *handlers* connect all kinds of web servers to Rack:
15
31
  * Mongrel
16
- * Mongrel/Swiftcore (require it before requiring rack)
32
+ * EventedMongrel
17
33
  * WEBrick
18
34
  * FCGI
19
35
  * CGI
@@ -23,6 +39,7 @@ The included *handlers* connect all kinds of web servers to Rack:
23
39
  These web servers include Rack handlers in their distributions:
24
40
  * Ebb
25
41
  * Fuzed
42
+ * Phusion Passenger (which is mod_rack for Apache)
26
43
  * Thin
27
44
 
28
45
  Any valid Rack app will run the same on all these handlers, without
@@ -36,12 +53,14 @@ The included *adapters* connect Rack with existing Ruby web frameworks:
36
53
  These frameworks include Rack adapters in their distributions:
37
54
  * Coset
38
55
  * Halcyon
56
+ * Mack
39
57
  * Maveric
40
58
  * Merb
41
59
  * Racktools::SimpleApplication
42
60
  * Ramaze
43
61
  * Sinatra
44
62
  * Vintage
63
+ * Waves
45
64
 
46
65
  Ruby on Rails can be run with the adapter included with Thin, which
47
66
  will be merged into a later Rack version.
@@ -61,8 +80,8 @@ applications needs using middleware, for example:
61
80
  * ...many others!
62
81
 
63
82
  All these components use the same interface, which is described in
64
- detail in the Rack specification. You can choose to use them exactly
65
- in the way you want.
83
+ detail in the Rack specification. These optional components can be
84
+ used in any way you wish.
66
85
 
67
86
  == Convenience
68
87
 
@@ -112,6 +131,53 @@ at my site:
112
131
 
113
132
  gem install rack --source http://chneukirchen.org/releases/gems
114
133
 
134
+ == Running the tests
135
+
136
+ Testing Rack requires the test/spec testing framework:
137
+
138
+ gem install test-spec
139
+
140
+ There are two rake-based test tasks:
141
+
142
+ rake test tests all the fast tests (no Handlers or Adapters)
143
+ rake fulltest runs all the tests
144
+
145
+ The fast testsuite has no dependencies outside of the core Ruby
146
+ installation and test-spec.
147
+
148
+ To run the test suite completely, you need:
149
+
150
+ * camping
151
+ * mongrel
152
+ * fcgi
153
+ * ruby-openid
154
+ * memcache-client
155
+
156
+ The full set of tests test FCGI access with lighttpd (on port
157
+ 9203) so you will need lighttpd installed as well as the FCGI
158
+ libraries and the fcgi gem:
159
+
160
+ Download and install lighttpd:
161
+
162
+ http://www.lighttpd.net/download
163
+
164
+ Installing the FCGI libraries:
165
+
166
+ curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
167
+ tar xzvf fcgi-2.4.0.tar.gz
168
+ cd fcgi-2.4.0
169
+ ./configure --prefix=/usr/local
170
+ make
171
+ sudo make install
172
+ cd ..
173
+
174
+ Installing the Ruby fcgi gem:
175
+
176
+ gem install fcgi
177
+
178
+ Furthermore, to test Memcache sessions, you need memcached (will be
179
+ run on port 11211) and memcache-client installed.
180
+
115
181
  == History
116
182
 
117
183
  * March 3rd, 2007: First public release 0.1.
@@ -138,27 +204,45 @@ at my site:
138
204
  * HTTP status 201 can contain a Content-Type and a body now.
139
205
  * Many bugfixes, especially related to Cookie handling.
140
206
 
207
+ * August 21th, 2008: Fourth public release 0.4.
208
+ * New middleware, Rack::Deflater, by Christoffer Sawicki.
209
+ * OpenID authentication now needs ruby-openid 2.
210
+ * New Memcache sessions, by blink.
211
+ * Explicit EventedMongrel handler, by Joshua Peek <josh@joshpeek.com>
212
+ * Rack::Reloader is not loaded in rackup development mode.
213
+ * rackup can daemonize with -D.
214
+ * Many bugfixes, especially for pool sessions, URLMap, thread safety
215
+ and tempfile handling.
216
+ * Improved tests.
217
+ * Rack moved to Git.
218
+
141
219
  == Contact
142
220
 
143
221
  Please mail bugs, suggestions and patches to
144
- <mailto:chneukirchen@gmail.com>.
222
+ <mailto:rack-devel@googlegroups.com>.
223
+
224
+ Mailing list archives are available at
225
+ <http://groups.google.com/group/rack-devel>
145
226
 
146
- Darcs repository ("darcs send" is welcome for patches):
147
- http://chneukirchen.org/repos/rack
227
+ Git repository (branches rebased on master are most welcome):
228
+ * http://github.com/chneukirchen/rack
229
+ * http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack.git
148
230
 
149
231
  You are also welcome to join the #rack channel on irc.freenode.net.
150
232
 
151
233
  == Thanks to
152
234
 
235
+ * blink for the Pool sessions, Memcache sessions, OpenID support, many
236
+ tweaks, patches and bugreports.
153
237
  * Michael Fellinger, for the helpful discussion, bugfixes and a better
154
238
  Rack::Request interface.
155
239
  * Adrian Madrid, for the LiteSpeed handler.
156
- * Christoffer Sawicki, for the Rails adapter.
240
+ * Christoffer Sawicki, for the first Rails adapter and Rack::Deflater.
157
241
  * Tim Fletcher, for the HTTP authentication code.
158
242
  * Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
159
- * blink for the Pool sessions, OpenID support, various tweaks, and bugreports.
160
243
  * Armin Ronacher, for the logo and racktools.
161
244
  * Aredridel, for bug fixing.
245
+ * Stephen Bannasch, for bug reports and documentation.
162
246
  * Gary Wright, for proposing a better Rack::Response interface.
163
247
  * Jonathan Buch, for improvements regarding Rack::Response.
164
248
  * Armin Röhrl, for tracking down bugs in the Cookie generator.
@@ -166,6 +250,7 @@ You are also welcome to join the #rack channel on irc.freenode.net.
166
250
  * Marcus Rückert, for help with configuring and debugging lighttpd.
167
251
  * The WSGI team for the well-done and documented work they've done and
168
252
  Rack builds up on.
253
+ * All bug reporters and patch contributers not mentioned above.
169
254
 
170
255
  == Copyright
171
256
 
@@ -192,11 +277,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
192
277
 
193
278
  Rack:: <http://rack.rubyforge.org/>
194
279
  Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
280
+ rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
195
281
 
196
282
  Camping:: <http://camping.rubyforge.org/>
197
283
  Ramaze:: <http://ramaze.rubyforge.org/>
198
284
  Maveric:: <http://maveric.rubyforge.org/>
199
- racktools:: <http://lucumr.pocoo.org/trac/repos/racktools/>
200
285
 
201
286
  Christian Neukirchen:: <http://chneukirchen.org/>
202
287
 
data/Rakefile CHANGED
@@ -11,43 +11,35 @@ task :predist => [:chmod, :changelog, :rdoc]
11
11
 
12
12
 
13
13
  desc "Make an archive as .tar.gz"
14
- task :dist => :fulltest do
15
- sh "export DARCS_REPO=#{File.expand_path "."}; " +
16
- "darcs dist -d rack-#{get_darcs_tree_version}"
14
+ task :dist => [:fulltest, :predist] do
15
+ sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
16
+ sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX SPEC ChangeLog doc"
17
+ sh "gzip -f -9 #{release}.tar"
17
18
  end
18
19
 
19
- # Helper to retrieve the "revision number" of the darcs tree.
20
- def get_darcs_tree_version
21
- unless File.directory? "_darcs"
20
+ # Helper to retrieve the "revision number" of the git tree.
21
+ def git_tree_version
22
+ if File.directory?(".git")
23
+ @tree_version ||= `git describe`.strip.sub('-', '.')
24
+ @tree_version << ".0" unless @tree_version.count('.') == 2
25
+ else
22
26
  $: << "lib"
23
27
  require 'rack'
24
- return Rack.version
28
+ @tree_version = Rack.release
25
29
  end
30
+ @tree_version
31
+ end
26
32
 
27
- changes = `darcs changes`
28
- count = 0
29
- tag = "0.0"
30
-
31
- changes.split("\n\n").each { |change|
32
- head, title, desc = change.split("\n", 3)
33
-
34
- if title =~ /^ \*/
35
- # Normal change.
36
- count += 1
37
- elsif title =~ /tagged (.*)/
38
- # Tag. We look for these.
39
- tag = $1
40
- break
41
- else
42
- warn "Unparsable change: #{change}"
43
- end
44
- }
33
+ def gem_version
34
+ git_tree_version.gsub(/-.*/, '')
35
+ end
45
36
 
46
- tag + "." + count.to_s
37
+ def release
38
+ "rack-#{git_tree_version}"
47
39
  end
48
40
 
49
41
  def manifest
50
- `darcs query manifest`.split("\n").map { |f| f.gsub(/\A\.\//, '') }
42
+ `git ls-files`.split("\n")
51
43
  end
52
44
 
53
45
 
@@ -59,7 +51,20 @@ end
59
51
 
60
52
  desc "Generate a ChangeLog"
61
53
  task :changelog do
62
- sh "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog"
54
+ File.open("ChangeLog", "w") { |out|
55
+ `git log -z`.split("\0").map { |chunk|
56
+ author = chunk[/Author: (.*)/, 1].strip
57
+ date = chunk[/Date: (.*)/, 1].strip
58
+ desc, detail = $'.strip.split("\n", 2)
59
+ detail ||= ""
60
+ detail = detail.gsub(/.*darcs-hash:.*/, '')
61
+ detail.rstrip!
62
+ out.puts "#{date} #{author}"
63
+ out.puts " * #{desc.strip}"
64
+ out.puts detail unless detail.empty?
65
+ out.puts
66
+ }
67
+ }
63
68
  end
64
69
 
65
70
 
@@ -81,16 +86,15 @@ end
81
86
 
82
87
  desc "Run all the fast tests"
83
88
  task :test do
84
- sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS'] || '-t "^(?!Rack::Handler|Rack::Adapter)"'}"
89
+ sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS'] || '-t "^(?!Rack::Handler|Rack::Adapter|Rack::Session::Memcache|Rack::Auth::OpenID)"'}"
85
90
  end
86
91
 
87
92
  desc "Run all the tests"
88
- task :fulltest do
93
+ task :fulltest => [:chmod] do
89
94
  sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
90
95
  end
91
96
 
92
97
  begin
93
- $" << "sources" if defined? FromSrc
94
98
  require 'rubygems'
95
99
 
96
100
  require 'rake'
@@ -103,7 +107,7 @@ rescue LoadError
103
107
  else
104
108
  spec = Gem::Specification.new do |s|
105
109
  s.name = "rack"
106
- s.version = get_darcs_tree_version
110
+ s.version = gem_version
107
111
  s.platform = Gem::Platform::RUBY
108
112
  s.summary = "a modular Ruby webserver interface"
109
113
 
data/SPEC CHANGED
@@ -14,7 +14,6 @@ and the *body*.
14
14
  The environment must be an true instance of Hash (no
15
15
  subclassing allowed) that includes CGI-like headers.
16
16
  The application is free to modify the environment.
17
-
18
17
  The environment is required to include these variables
19
18
  (adopted from PEP333), except when they'd be empty, but see
20
19
  below.
@@ -63,12 +62,10 @@ environment, too. The keys must contain at least one dot,
63
62
  and should be prefixed uniquely. The prefix <tt>rack.</tt>
64
63
  is reserved for use with the Rack core distribution and must
65
64
  not be used otherwise.
66
-
67
65
  The environment must not contain the keys
68
66
  <tt>HTTP_CONTENT_TYPE</tt> or <tt>HTTP_CONTENT_LENGTH</tt>
69
67
  (use the versions without <tt>HTTP_</tt>).
70
68
  The CGI keys (named without a period) must have String values.
71
-
72
69
  There are the following restrictions:
73
70
  * <tt>rack.version</tt> must be an array of Integers.
74
71
  * <tt>rack.url_scheme</tt> must either be +http+ or +https+.
@@ -100,7 +97,7 @@ The error stream must respond to +puts+, +write+ and +flush+.
100
97
  * +close+ must never be called on the error stream.
101
98
  == The Response
102
99
  === The Status
103
- The status, if parsed as integer (+to_i+), must be bigger than 100.
100
+ The status, if parsed as integer (+to_i+), must be greater than or equal to 100.
104
101
  === The Headers
105
102
  The header must respond to each, and yield values of key and value.
106
103
  The header keys must be Strings.
@@ -109,7 +106,6 @@ contain keys with <tt>:</tt> or newlines in their name,
109
106
  contain keys names that end in <tt>-</tt> or <tt>_</tt>,
110
107
  but only contain keys that consist of
111
108
  letters, digits, <tt>_</tt> or <tt>-</tt> and start with a letter.
112
-
113
109
  The values of the header must respond to #each.
114
110
  The values passed on #each must be Strings
115
111
  and not contain characters below 037.
@@ -120,9 +116,7 @@ given.
120
116
  === The Body
121
117
  The Body must respond to #each
122
118
  and must only yield String values.
123
-
124
119
  If the Body responds to #close, it will be called after iteration.
125
-
126
120
  The Body commonly is an Array of Strings, the application
127
121
  instance itself, or a File-like object.
128
122
  == Thanks