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.
- data/AUTHORS +1 -0
- data/RDOX +61 -3
- data/README +94 -9
- data/Rakefile +36 -32
- data/SPEC +1 -7
- data/bin/rackup +31 -13
- data/lib/rack.rb +8 -19
- data/lib/rack/auth/digest/params.rb +2 -2
- data/lib/rack/auth/openid.rb +406 -80
- data/lib/rack/builder.rb +1 -1
- data/lib/rack/cascade.rb +10 -0
- data/lib/rack/commonlogger.rb +6 -1
- data/lib/rack/deflater.rb +63 -0
- data/lib/rack/directory.rb +158 -0
- data/lib/rack/file.rb +11 -5
- data/lib/rack/handler.rb +44 -0
- data/lib/rack/handler/evented_mongrel.rb +8 -0
- data/lib/rack/handler/fastcgi.rb +1 -0
- data/lib/rack/handler/mongrel.rb +21 -1
- data/lib/rack/lint.rb +20 -13
- data/lib/rack/mock.rb +1 -0
- data/lib/rack/request.rb +69 -2
- data/lib/rack/session/abstract/id.rb +140 -0
- data/lib/rack/session/memcache.rb +97 -0
- data/lib/rack/session/pool.rb +50 -59
- data/lib/rack/showstatus.rb +3 -1
- data/lib/rack/urlmap.rb +12 -12
- data/lib/rack/utils.rb +88 -9
- data/test/cgi/lighttpd.conf +1 -1
- data/test/cgi/test.fcgi +1 -2
- data/test/cgi/test.ru +2 -2
- data/test/spec_rack_auth_openid.rb +137 -0
- data/test/spec_rack_camping.rb +37 -33
- data/test/spec_rack_cascade.rb +15 -0
- data/test/spec_rack_cgi.rb +4 -3
- data/test/spec_rack_deflater.rb +70 -0
- data/test/spec_rack_directory.rb +56 -0
- data/test/spec_rack_fastcgi.rb +4 -3
- data/test/spec_rack_file.rb +11 -1
- data/test/spec_rack_handler.rb +24 -0
- data/test/spec_rack_lint.rb +19 -33
- data/test/spec_rack_mongrel.rb +71 -0
- data/test/spec_rack_request.rb +91 -1
- data/test/spec_rack_session_memcache.rb +132 -0
- data/test/spec_rack_session_pool.rb +48 -1
- data/test/spec_rack_showstatus.rb +5 -4
- data/test/spec_rack_urlmap.rb +60 -25
- data/test/spec_rack_utils.rb +118 -1
- data/test/testrequest.rb +3 -1
- metadata +67 -44
data/test/spec_rack_utils.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
require 'test/spec'
|
2
|
+
|
1
3
|
require 'rack/utils'
|
4
|
+
require 'rack/lint'
|
5
|
+
require 'rack/mock'
|
2
6
|
|
3
7
|
context "Rack::Utils" do
|
4
8
|
specify "should escape correctly" do
|
@@ -16,13 +20,48 @@ context "Rack::Utils" do
|
|
16
20
|
should.equal "q1!2\"'w$5&7/z8)?\\"
|
17
21
|
end
|
18
22
|
|
19
|
-
specify "should parse
|
23
|
+
specify "should parse query strings correctly" do
|
20
24
|
Rack::Utils.parse_query("foo=bar").should.equal "foo" => "bar"
|
21
25
|
Rack::Utils.parse_query("foo=bar&foo=quux").
|
22
26
|
should.equal "foo" => ["bar", "quux"]
|
27
|
+
Rack::Utils.parse_query("foo=1&bar=2").
|
28
|
+
should.equal "foo" => "1", "bar" => "2"
|
23
29
|
Rack::Utils.parse_query("my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F").
|
24
30
|
should.equal "my weird field" => "q1!2\"'w$5&7/z8)?"
|
25
31
|
end
|
32
|
+
|
33
|
+
specify "should build query strings correctly" do
|
34
|
+
Rack::Utils.build_query("foo" => "bar").should.equal "foo=bar"
|
35
|
+
Rack::Utils.build_query("foo" => ["bar", "quux"]).
|
36
|
+
should.equal "foo=bar&foo=quux"
|
37
|
+
Rack::Utils.build_query("foo" => "1", "bar" => "2").
|
38
|
+
should.equal "foo=1&bar=2"
|
39
|
+
Rack::Utils.build_query("my weird field" => "q1!2\"'w$5&7/z8)?").
|
40
|
+
should.equal "my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F"
|
41
|
+
end
|
42
|
+
|
43
|
+
specify "should figure out which encodings are acceptable" do
|
44
|
+
helper = lambda do |a, b|
|
45
|
+
request = Rack::Request.new(Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => a))
|
46
|
+
Rack::Utils.select_best_encoding(a, b)
|
47
|
+
end
|
48
|
+
|
49
|
+
helper.call(%w(), [["x", 1]]).should.equal(nil)
|
50
|
+
helper.call(%w(identity), [["identity", 0.0]]).should.equal(nil)
|
51
|
+
helper.call(%w(identity), [["*", 0.0]]).should.equal(nil)
|
52
|
+
|
53
|
+
helper.call(%w(identity), [["compress", 1.0], ["gzip", 1.0]]).should.equal("identity")
|
54
|
+
|
55
|
+
helper.call(%w(compress gzip identity), [["compress", 1.0], ["gzip", 1.0]]).should.equal("compress")
|
56
|
+
helper.call(%w(compress gzip identity), [["compress", 0.5], ["gzip", 1.0]]).should.equal("gzip")
|
57
|
+
|
58
|
+
helper.call(%w(foo bar identity), []).should.equal("identity")
|
59
|
+
helper.call(%w(foo bar identity), [["*", 1.0]]).should.equal("foo")
|
60
|
+
helper.call(%w(foo bar identity), [["*", 1.0], ["foo", 0.9]]).should.equal("bar")
|
61
|
+
|
62
|
+
helper.call(%w(foo bar identity), [["foo", 0], ["bar", 0]]).should.equal("identity")
|
63
|
+
helper.call(%w(foo bar baz identity), [["*", 0], ["identity", 0.1]]).should.equal("identity")
|
64
|
+
end
|
26
65
|
end
|
27
66
|
|
28
67
|
context "Rack::Utils::HeaderHash" do
|
@@ -55,3 +94,81 @@ context "Rack::Utils::HeaderHash" do
|
|
55
94
|
h.to_hash.should.be.instance_of Hash
|
56
95
|
end
|
57
96
|
end
|
97
|
+
|
98
|
+
context "Rack::Utils::Context" do
|
99
|
+
test_app1 = Object.new
|
100
|
+
def test_app1.context app
|
101
|
+
Rack::Utils::Context.new self, app do |env|
|
102
|
+
app.call env
|
103
|
+
end
|
104
|
+
end
|
105
|
+
test_app2 = Object.new
|
106
|
+
def test_app2.context env; end
|
107
|
+
test_app3 = Object.new
|
108
|
+
test_target1 = proc{|e| e.to_s+' world' }
|
109
|
+
test_target2 = proc{|e| e.to_i+2 }
|
110
|
+
test_target3 = proc{|e| nil }
|
111
|
+
test_target4 = proc{|e| [200,{'Content-Type'=>'text/plain', 'Content-Length'=>'0'},['']] }
|
112
|
+
test_target5 = Object.new
|
113
|
+
|
114
|
+
specify "should perform checks on both arguments" do
|
115
|
+
lambda { Rack::Utils::Context.new(nil, nil){} }.should.raise
|
116
|
+
lambda { Rack::Utils::Context.new(test_app1, nil){} }.should.raise
|
117
|
+
lambda { Rack::Utils::Context.new(nil, test_target1){} }.should.raise
|
118
|
+
lambda { Rack::Utils::Context.new(test_app1, test_target1){} }.should.not.raise
|
119
|
+
lambda { Rack::Utils::Context.new(test_app3, test_target1){} }.should.raise
|
120
|
+
lambda { Rack::Utils::Context.new(test_app1, test_target5){} }.should.raise
|
121
|
+
lambda { test_app1.context(nil){} }.should.raise
|
122
|
+
lambda { test_app1.context(test_target1){} }.should.not.raise
|
123
|
+
lambda { test_app1.context(test_target5){} }.should.raise
|
124
|
+
end
|
125
|
+
|
126
|
+
specify "should set context correctly" do
|
127
|
+
c1 = Rack::Utils::Context.new(test_app1, test_target1){}
|
128
|
+
c1.for.should.equal test_app1
|
129
|
+
c1.app.should.equal test_target1
|
130
|
+
c2 = Rack::Utils::Context.new(test_app1, test_target2){}
|
131
|
+
c2.for.should.equal test_app1
|
132
|
+
c2.app.should.equal test_target2
|
133
|
+
c3 = Rack::Utils::Context.new(test_app2, test_target3){}
|
134
|
+
c3.for.should.equal test_app2
|
135
|
+
c3.app.should.equal test_target3
|
136
|
+
c4 = Rack::Utils::Context.new(test_app2, test_target4){}
|
137
|
+
c4.for.should.equal test_app2
|
138
|
+
c4.app.should.equal test_target4
|
139
|
+
end
|
140
|
+
|
141
|
+
specify "should alter app on recontexting" do
|
142
|
+
c1 = Rack::Utils::Context.new(test_app1, test_target1){}
|
143
|
+
c1.for.should.equal test_app1
|
144
|
+
c1.app.should.equal test_target1
|
145
|
+
c2 = c1.context(test_target2)
|
146
|
+
c2.for.should.equal test_app1
|
147
|
+
c2.app.should.not.equal test_target1
|
148
|
+
c2.app.should.equal test_target2
|
149
|
+
c3 = c2.context(test_target3)
|
150
|
+
c3.for.should.equal test_app1
|
151
|
+
c3.app.should.not.equal test_target2
|
152
|
+
c3.app.should.equal test_target3
|
153
|
+
c4 = c3.context(test_target4)
|
154
|
+
c4.for.should.equal test_app1
|
155
|
+
c4.app.should.not.equal test_target3
|
156
|
+
c4.app.should.equal test_target4
|
157
|
+
end
|
158
|
+
|
159
|
+
specify "should run different apps" do
|
160
|
+
c1 = test_app1.context(test_target1)
|
161
|
+
c2 = c1.context test_target2
|
162
|
+
c3 = c2.context test_target3
|
163
|
+
c4 = c3.context test_target4
|
164
|
+
a4 = Rack::Lint.new c4
|
165
|
+
r1 = c1.call('hello')
|
166
|
+
r1.should.equal 'hello world'
|
167
|
+
r2 = c2.call(2)
|
168
|
+
r2.should.equal 4
|
169
|
+
r3 = c3.call(:misc_symbol)
|
170
|
+
r3.should.be.nil
|
171
|
+
r4 = Rack::MockRequest.new(a4).get('/')
|
172
|
+
r4.status.should.be 200
|
173
|
+
end
|
174
|
+
end
|
data/test/testrequest.rb
CHANGED
@@ -5,7 +5,9 @@ class TestRequest
|
|
5
5
|
def call(env)
|
6
6
|
status = env["QUERY_STRING"] =~ /secret/ ? 403 : 200
|
7
7
|
env["test.postdata"] = env["rack.input"].read
|
8
|
-
|
8
|
+
body = env.to_yaml
|
9
|
+
size = body.respond_to?(:bytesize) ? body.bytesize : body.size
|
10
|
+
[status, {"Content-Type" => "text/yaml", "Content-Length" => size.to_s}, [body]]
|
9
11
|
end
|
10
12
|
|
11
13
|
module Helpers
|
metadata
CHANGED
@@ -1,42 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: rack
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2008-02-26 00:00:00 +01:00
|
8
|
-
summary: a modular Ruby webserver interface
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: chneukirchen@gmail.com
|
12
|
-
homepage: http://rack.rubyforge.org
|
13
|
-
rubyforge_project: rack
|
14
|
-
description: Rack provides minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call. Also see http://rack.rubyforge.org.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.4.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Christian Neukirchen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-21 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Rack provides minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call. Also see http://rack.rubyforge.org.
|
17
|
+
email: chneukirchen@gmail.com
|
18
|
+
executables:
|
19
|
+
- rackup
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- SPEC
|
25
|
+
- RDOX
|
26
|
+
- KNOWN-ISSUES
|
31
27
|
files:
|
32
28
|
- AUTHORS
|
29
|
+
- COPYING
|
30
|
+
- KNOWN-ISSUES
|
31
|
+
- README
|
32
|
+
- Rakefile
|
33
33
|
- bin/rackup
|
34
34
|
- contrib/rack_logo.svg
|
35
|
-
- COPYING
|
36
35
|
- example/lobster.ru
|
37
36
|
- example/protectedlobster.rb
|
38
37
|
- example/protectedlobster.ru
|
39
|
-
-
|
38
|
+
- lib/rack.rb
|
40
39
|
- lib/rack/adapter/camping.rb
|
41
40
|
- lib/rack/auth/abstract/handler.rb
|
42
41
|
- lib/rack/auth/abstract/request.rb
|
@@ -49,8 +48,12 @@ files:
|
|
49
48
|
- lib/rack/builder.rb
|
50
49
|
- lib/rack/cascade.rb
|
51
50
|
- lib/rack/commonlogger.rb
|
51
|
+
- lib/rack/deflater.rb
|
52
|
+
- lib/rack/directory.rb
|
52
53
|
- lib/rack/file.rb
|
54
|
+
- lib/rack/handler.rb
|
53
55
|
- lib/rack/handler/cgi.rb
|
56
|
+
- lib/rack/handler/evented_mongrel.rb
|
54
57
|
- lib/rack/handler/fastcgi.rb
|
55
58
|
- lib/rack/handler/lsws.rb
|
56
59
|
- lib/rack/handler/mongrel.rb
|
@@ -63,29 +66,32 @@ files:
|
|
63
66
|
- lib/rack/reloader.rb
|
64
67
|
- lib/rack/request.rb
|
65
68
|
- lib/rack/response.rb
|
69
|
+
- lib/rack/session/abstract/id.rb
|
66
70
|
- lib/rack/session/cookie.rb
|
71
|
+
- lib/rack/session/memcache.rb
|
67
72
|
- lib/rack/session/pool.rb
|
68
73
|
- lib/rack/showexceptions.rb
|
69
74
|
- lib/rack/showstatus.rb
|
70
75
|
- lib/rack/static.rb
|
71
76
|
- lib/rack/urlmap.rb
|
72
77
|
- lib/rack/utils.rb
|
73
|
-
- lib/rack.rb
|
74
|
-
- Rakefile
|
75
|
-
- README
|
76
78
|
- test/cgi/lighttpd.conf
|
77
79
|
- test/cgi/test
|
78
80
|
- test/cgi/test.fcgi
|
79
81
|
- test/cgi/test.ru
|
80
82
|
- test/spec_rack_auth_basic.rb
|
81
83
|
- test/spec_rack_auth_digest.rb
|
84
|
+
- test/spec_rack_auth_openid.rb
|
82
85
|
- test/spec_rack_builder.rb
|
83
86
|
- test/spec_rack_camping.rb
|
84
87
|
- test/spec_rack_cascade.rb
|
85
88
|
- test/spec_rack_cgi.rb
|
86
89
|
- test/spec_rack_commonlogger.rb
|
90
|
+
- test/spec_rack_deflater.rb
|
91
|
+
- test/spec_rack_directory.rb
|
87
92
|
- test/spec_rack_fastcgi.rb
|
88
93
|
- test/spec_rack_file.rb
|
94
|
+
- test/spec_rack_handler.rb
|
89
95
|
- test/spec_rack_lint.rb
|
90
96
|
- test/spec_rack_lobster.rb
|
91
97
|
- test/spec_rack_mock.rb
|
@@ -94,6 +100,7 @@ files:
|
|
94
100
|
- test/spec_rack_request.rb
|
95
101
|
- test/spec_rack_response.rb
|
96
102
|
- test/spec_rack_session_cookie.rb
|
103
|
+
- test/spec_rack_session_memcache.rb
|
97
104
|
- test/spec_rack_session_pool.rb
|
98
105
|
- test/spec_rack_showexceptions.rb
|
99
106
|
- test/spec_rack_showstatus.rb
|
@@ -104,16 +111,46 @@ files:
|
|
104
111
|
- test/testrequest.rb
|
105
112
|
- SPEC
|
106
113
|
- RDOX
|
114
|
+
has_rdoc: true
|
115
|
+
homepage: http://rack.rubyforge.org
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: "0"
|
126
|
+
version:
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: "0"
|
132
|
+
version:
|
133
|
+
requirements: []
|
134
|
+
|
135
|
+
rubyforge_project: rack
|
136
|
+
rubygems_version: 1.0.1
|
137
|
+
signing_key:
|
138
|
+
specification_version: 2
|
139
|
+
summary: a modular Ruby webserver interface
|
107
140
|
test_files:
|
108
141
|
- test/spec_rack_auth_basic.rb
|
109
142
|
- test/spec_rack_auth_digest.rb
|
143
|
+
- test/spec_rack_auth_openid.rb
|
110
144
|
- test/spec_rack_builder.rb
|
111
145
|
- test/spec_rack_camping.rb
|
112
146
|
- test/spec_rack_cascade.rb
|
113
147
|
- test/spec_rack_cgi.rb
|
114
148
|
- test/spec_rack_commonlogger.rb
|
149
|
+
- test/spec_rack_deflater.rb
|
150
|
+
- test/spec_rack_directory.rb
|
115
151
|
- test/spec_rack_fastcgi.rb
|
116
152
|
- test/spec_rack_file.rb
|
153
|
+
- test/spec_rack_handler.rb
|
117
154
|
- test/spec_rack_lint.rb
|
118
155
|
- test/spec_rack_lobster.rb
|
119
156
|
- test/spec_rack_mock.rb
|
@@ -122,6 +159,7 @@ test_files:
|
|
122
159
|
- test/spec_rack_request.rb
|
123
160
|
- test/spec_rack_response.rb
|
124
161
|
- test/spec_rack_session_cookie.rb
|
162
|
+
- test/spec_rack_session_memcache.rb
|
125
163
|
- test/spec_rack_session_pool.rb
|
126
164
|
- test/spec_rack_showexceptions.rb
|
127
165
|
- test/spec_rack_showstatus.rb
|
@@ -129,18 +167,3 @@ test_files:
|
|
129
167
|
- test/spec_rack_urlmap.rb
|
130
168
|
- test/spec_rack_utils.rb
|
131
169
|
- test/spec_rack_webrick.rb
|
132
|
-
rdoc_options: []
|
133
|
-
|
134
|
-
extra_rdoc_files:
|
135
|
-
- README
|
136
|
-
- SPEC
|
137
|
-
- RDOX
|
138
|
-
- KNOWN-ISSUES
|
139
|
-
executables:
|
140
|
-
- rackup
|
141
|
-
extensions: []
|
142
|
-
|
143
|
-
requirements: []
|
144
|
-
|
145
|
-
dependencies: []
|
146
|
-
|