rack 1.6.13 → 2.0.1
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.
- checksums.yaml +5 -5
- data/COPYING +1 -1
- data/HISTORY.md +138 -8
- data/README.rdoc +17 -25
- data/Rakefile +6 -14
- data/SPEC +8 -9
- data/contrib/rack_logo.svg +164 -111
- data/example/protectedlobster.rb +1 -1
- data/example/protectedlobster.ru +1 -1
- data/lib/rack/auth/abstract/request.rb +5 -1
- data/lib/rack/auth/digest/params.rb +2 -3
- data/lib/rack/auth/digest/request.rb +1 -1
- data/lib/rack/body_proxy.rb +14 -9
- data/lib/rack/builder.rb +3 -3
- data/lib/rack/chunked.rb +5 -5
- data/lib/rack/{commonlogger.rb → common_logger.rb} +3 -3
- data/lib/rack/{conditionalget.rb → conditional_get.rb} +0 -0
- data/lib/rack/content_length.rb +2 -2
- data/lib/rack/deflater.rb +4 -4
- data/lib/rack/directory.rb +66 -54
- data/lib/rack/etag.rb +4 -3
- data/lib/rack/events.rb +154 -0
- data/lib/rack/file.rb +63 -39
- data/lib/rack/handler/cgi.rb +15 -16
- data/lib/rack/handler/fastcgi.rb +13 -14
- data/lib/rack/handler/lsws.rb +11 -11
- data/lib/rack/handler/scgi.rb +15 -15
- data/lib/rack/handler/thin.rb +3 -0
- data/lib/rack/handler/webrick.rb +22 -24
- data/lib/rack/handler.rb +3 -25
- data/lib/rack/head.rb +15 -17
- data/lib/rack/lint.rb +38 -38
- data/lib/rack/lobster.rb +1 -1
- data/lib/rack/lock.rb +6 -10
- data/lib/rack/logger.rb +2 -2
- data/lib/rack/media_type.rb +38 -0
- data/lib/rack/{methodoverride.rb → method_override.rb} +4 -11
- data/lib/rack/mime.rb +18 -5
- data/lib/rack/mock.rb +35 -53
- data/lib/rack/multipart/generator.rb +5 -5
- data/lib/rack/multipart/parser.rb +272 -158
- data/lib/rack/multipart/uploaded_file.rb +1 -2
- data/lib/rack/multipart.rb +35 -6
- data/lib/rack/{nulllogger.rb → null_logger.rb} +1 -1
- data/lib/rack/query_parser.rb +192 -0
- data/lib/rack/recursive.rb +8 -8
- data/lib/rack/request.rb +383 -307
- data/lib/rack/response.rb +129 -56
- data/lib/rack/rewindable_input.rb +1 -12
- data/lib/rack/runtime.rb +10 -18
- data/lib/rack/sendfile.rb +5 -7
- data/lib/rack/server.rb +31 -25
- data/lib/rack/session/abstract/id.rb +95 -135
- data/lib/rack/session/cookie.rb +26 -28
- data/lib/rack/session/memcache.rb +8 -14
- data/lib/rack/session/pool.rb +14 -21
- data/lib/rack/show_exceptions.rb +386 -0
- data/lib/rack/{showstatus.rb → show_status.rb} +3 -3
- data/lib/rack/static.rb +30 -5
- data/lib/rack/tempfile_reaper.rb +2 -2
- data/lib/rack/urlmap.rb +15 -14
- data/lib/rack/utils.rb +135 -210
- data/lib/rack.rb +70 -21
- data/rack.gemspec +7 -5
- data/test/builder/an_underscore_app.rb +5 -0
- data/test/builder/options.ru +1 -1
- data/test/cgi/test.fcgi +1 -0
- data/test/cgi/test.gz +0 -0
- data/test/helper.rb +34 -0
- data/test/multipart/filename_with_encoded_words +7 -0
- data/test/multipart/{filename_with_null_byte → filename_with_single_quote} +1 -1
- data/test/multipart/quoted +15 -0
- data/test/multipart/rack-logo.png +0 -0
- data/test/multipart/unity3d_wwwform +11 -0
- data/test/registering_handler/rack/handler/registering_myself.rb +1 -1
- data/test/spec_auth_basic.rb +27 -19
- data/test/spec_auth_digest.rb +47 -46
- data/test/spec_body_proxy.rb +27 -27
- data/test/spec_builder.rb +51 -41
- data/test/spec_cascade.rb +24 -22
- data/test/spec_cgi.rb +49 -67
- data/test/spec_chunked.rb +36 -34
- data/test/{spec_commonlogger.rb → spec_common_logger.rb} +23 -21
- data/test/{spec_conditionalget.rb → spec_conditional_get.rb} +29 -28
- data/test/spec_config.rb +3 -2
- data/test/spec_content_length.rb +18 -17
- data/test/spec_content_type.rb +13 -12
- data/test/spec_deflater.rb +66 -40
- data/test/spec_directory.rb +87 -27
- data/test/spec_etag.rb +32 -31
- data/test/spec_events.rb +133 -0
- data/test/spec_fastcgi.rb +50 -72
- data/test/spec_file.rb +107 -77
- data/test/spec_handler.rb +19 -34
- data/test/spec_head.rb +15 -14
- data/test/spec_lint.rb +162 -197
- data/test/spec_lobster.rb +24 -23
- data/test/spec_lock.rb +69 -39
- data/test/spec_logger.rb +4 -3
- data/test/spec_media_type.rb +42 -0
- data/test/spec_method_override.rb +83 -0
- data/test/spec_mime.rb +19 -19
- data/test/spec_mock.rb +196 -151
- data/test/spec_multipart.rb +317 -201
- data/test/{spec_nulllogger.rb → spec_null_logger.rb} +5 -4
- data/test/spec_recursive.rb +17 -14
- data/test/spec_request.rb +768 -607
- data/test/spec_response.rb +214 -111
- data/test/spec_rewindable_input.rb +50 -40
- data/test/spec_runtime.rb +11 -10
- data/test/spec_sendfile.rb +30 -35
- data/test/spec_server.rb +78 -52
- data/test/spec_session_abstract_id.rb +11 -33
- data/test/spec_session_abstract_session_hash.rb +28 -0
- data/test/spec_session_cookie.rb +97 -65
- data/test/spec_session_memcache.rb +63 -101
- data/test/spec_session_pool.rb +48 -84
- data/test/spec_show_exceptions.rb +80 -0
- data/test/{spec_showstatus.rb → spec_show_status.rb} +36 -35
- data/test/spec_static.rb +71 -32
- data/test/spec_tempfile_reaper.rb +11 -10
- data/test/spec_thin.rb +55 -50
- data/test/spec_urlmap.rb +79 -78
- data/test/spec_utils.rb +441 -346
- data/test/spec_version.rb +2 -8
- data/test/spec_webrick.rb +91 -67
- data/test/static/foo.html +1 -0
- data/test/testrequest.rb +1 -1
- data/test/unregistered_handler/rack/handler/unregistered.rb +1 -1
- data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +1 -1
- metadata +103 -69
- data/KNOWN-ISSUES +0 -44
- data/lib/rack/backports/uri/common_18.rb +0 -56
- data/lib/rack/backports/uri/common_192.rb +0 -52
- data/lib/rack/backports/uri/common_193.rb +0 -29
- data/lib/rack/handler/evented_mongrel.rb +0 -8
- data/lib/rack/handler/mongrel.rb +0 -106
- data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
- data/lib/rack/showexceptions.rb +0 -387
- data/lib/rack/utils/okjson.rb +0 -600
- data/test/spec_methodoverride.rb +0 -111
- data/test/spec_mongrel.rb +0 -182
- data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
- data/test/spec_showexceptions.rb +0 -98
data/test/spec_urlmap.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'minitest/autorun'
|
1
2
|
require 'rack/urlmap'
|
2
3
|
require 'rack/mock'
|
3
4
|
|
@@ -17,51 +18,51 @@ describe Rack::URLMap do
|
|
17
18
|
}))
|
18
19
|
|
19
20
|
res = Rack::MockRequest.new(map).get("/")
|
20
|
-
res.
|
21
|
+
res.must_be :not_found?
|
21
22
|
|
22
23
|
res = Rack::MockRequest.new(map).get("/qux")
|
23
|
-
res.
|
24
|
+
res.must_be :not_found?
|
24
25
|
|
25
26
|
res = Rack::MockRequest.new(map).get("/foo")
|
26
|
-
res.
|
27
|
-
res["X-ScriptName"].
|
28
|
-
res["X-PathInfo"].
|
27
|
+
res.must_be :ok?
|
28
|
+
res["X-ScriptName"].must_equal "/foo"
|
29
|
+
res["X-PathInfo"].must_equal ""
|
29
30
|
|
30
31
|
res = Rack::MockRequest.new(map).get("/foo/")
|
31
|
-
res.
|
32
|
-
res["X-ScriptName"].
|
33
|
-
res["X-PathInfo"].
|
32
|
+
res.must_be :ok?
|
33
|
+
res["X-ScriptName"].must_equal "/foo"
|
34
|
+
res["X-PathInfo"].must_equal "/"
|
34
35
|
|
35
36
|
res = Rack::MockRequest.new(map).get("/foo/bar")
|
36
|
-
res.
|
37
|
-
res["X-ScriptName"].
|
38
|
-
res["X-PathInfo"].
|
37
|
+
res.must_be :ok?
|
38
|
+
res["X-ScriptName"].must_equal "/foo/bar"
|
39
|
+
res["X-PathInfo"].must_equal ""
|
39
40
|
|
40
41
|
res = Rack::MockRequest.new(map).get("/foo/bar/")
|
41
|
-
res.
|
42
|
-
res["X-ScriptName"].
|
43
|
-
res["X-PathInfo"].
|
42
|
+
res.must_be :ok?
|
43
|
+
res["X-ScriptName"].must_equal "/foo/bar"
|
44
|
+
res["X-PathInfo"].must_equal "/"
|
44
45
|
|
45
46
|
res = Rack::MockRequest.new(map).get("/foo///bar//quux")
|
46
|
-
res.status.
|
47
|
-
res.
|
48
|
-
res["X-ScriptName"].
|
49
|
-
res["X-PathInfo"].
|
47
|
+
res.status.must_equal 200
|
48
|
+
res.must_be :ok?
|
49
|
+
res["X-ScriptName"].must_equal "/foo/bar"
|
50
|
+
res["X-PathInfo"].must_equal "//quux"
|
50
51
|
|
51
52
|
res = Rack::MockRequest.new(map).get("/foo/quux", "SCRIPT_NAME" => "/bleh")
|
52
|
-
res.
|
53
|
-
res["X-ScriptName"].
|
54
|
-
res["X-PathInfo"].
|
53
|
+
res.must_be :ok?
|
54
|
+
res["X-ScriptName"].must_equal "/bleh/foo"
|
55
|
+
res["X-PathInfo"].must_equal "/quux"
|
55
56
|
|
56
57
|
res = Rack::MockRequest.new(map).get("/bar", 'HTTP_HOST' => 'foo.org')
|
57
|
-
res.
|
58
|
-
res["X-ScriptName"].
|
59
|
-
res["X-PathInfo"].
|
58
|
+
res.must_be :ok?
|
59
|
+
res["X-ScriptName"].must_equal "/bar"
|
60
|
+
res["X-PathInfo"].must_be :empty?
|
60
61
|
|
61
62
|
res = Rack::MockRequest.new(map).get("/bar/", 'HTTP_HOST' => 'foo.org')
|
62
|
-
res.
|
63
|
-
res["X-ScriptName"].
|
64
|
-
res["X-PathInfo"].
|
63
|
+
res.must_be :ok?
|
64
|
+
res["X-ScriptName"].must_equal "/bar"
|
65
|
+
res["X-PathInfo"].must_equal '/'
|
65
66
|
end
|
66
67
|
|
67
68
|
|
@@ -93,37 +94,37 @@ describe Rack::URLMap do
|
|
93
94
|
))
|
94
95
|
|
95
96
|
res = Rack::MockRequest.new(map).get("/")
|
96
|
-
res.
|
97
|
-
res["X-Position"].
|
97
|
+
res.must_be :ok?
|
98
|
+
res["X-Position"].must_equal "default.org"
|
98
99
|
|
99
100
|
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "bar.org")
|
100
|
-
res.
|
101
|
-
res["X-Position"].
|
101
|
+
res.must_be :ok?
|
102
|
+
res["X-Position"].must_equal "bar.org"
|
102
103
|
|
103
104
|
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "foo.org")
|
104
|
-
res.
|
105
|
-
res["X-Position"].
|
105
|
+
res.must_be :ok?
|
106
|
+
res["X-Position"].must_equal "foo.org"
|
106
107
|
|
107
108
|
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "subdomain.foo.org", "SERVER_NAME" => "foo.org")
|
108
|
-
res.
|
109
|
-
res["X-Position"].
|
109
|
+
res.must_be :ok?
|
110
|
+
res["X-Position"].must_equal "subdomain.foo.org"
|
110
111
|
|
111
112
|
res = Rack::MockRequest.new(map).get("http://foo.org/")
|
112
|
-
res.
|
113
|
-
res["X-Position"].
|
113
|
+
res.must_be :ok?
|
114
|
+
res["X-Position"].must_equal "foo.org"
|
114
115
|
|
115
116
|
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org")
|
116
|
-
res.
|
117
|
-
res["X-Position"].
|
117
|
+
res.must_be :ok?
|
118
|
+
res["X-Position"].must_equal "default.org"
|
118
119
|
|
119
120
|
res = Rack::MockRequest.new(map).get("/",
|
120
121
|
"HTTP_HOST" => "example.org:9292",
|
121
122
|
"SERVER_PORT" => "9292")
|
122
|
-
res.
|
123
|
-
res["X-Position"].
|
123
|
+
res.must_be :ok?
|
124
|
+
res["X-Position"].must_equal "default.org"
|
124
125
|
end
|
125
126
|
|
126
|
-
|
127
|
+
it "be nestable" do
|
127
128
|
map = Rack::Lint.new(Rack::URLMap.new("/foo" =>
|
128
129
|
Rack::URLMap.new("/bar" =>
|
129
130
|
Rack::URLMap.new("/quux" => lambda { |env|
|
@@ -136,16 +137,16 @@ describe Rack::URLMap do
|
|
136
137
|
))))
|
137
138
|
|
138
139
|
res = Rack::MockRequest.new(map).get("/foo/bar")
|
139
|
-
res.
|
140
|
+
res.must_be :not_found?
|
140
141
|
|
141
142
|
res = Rack::MockRequest.new(map).get("/foo/bar/quux")
|
142
|
-
res.
|
143
|
-
res["X-Position"].
|
144
|
-
res["X-PathInfo"].
|
145
|
-
res["X-ScriptName"].
|
143
|
+
res.must_be :ok?
|
144
|
+
res["X-Position"].must_equal "/foo/bar/quux"
|
145
|
+
res["X-PathInfo"].must_equal ""
|
146
|
+
res["X-ScriptName"].must_equal "/foo/bar/quux"
|
146
147
|
end
|
147
148
|
|
148
|
-
|
149
|
+
it "route root apps correctly" do
|
149
150
|
map = Rack::Lint.new(Rack::URLMap.new("/" => lambda { |env|
|
150
151
|
[200,
|
151
152
|
{ "Content-Type" => "text/plain",
|
@@ -163,31 +164,31 @@ describe Rack::URLMap do
|
|
163
164
|
))
|
164
165
|
|
165
166
|
res = Rack::MockRequest.new(map).get("/foo/bar")
|
166
|
-
res.
|
167
|
-
res["X-Position"].
|
168
|
-
res["X-PathInfo"].
|
169
|
-
res["X-ScriptName"].
|
167
|
+
res.must_be :ok?
|
168
|
+
res["X-Position"].must_equal "foo"
|
169
|
+
res["X-PathInfo"].must_equal "/bar"
|
170
|
+
res["X-ScriptName"].must_equal "/foo"
|
170
171
|
|
171
172
|
res = Rack::MockRequest.new(map).get("/foo")
|
172
|
-
res.
|
173
|
-
res["X-Position"].
|
174
|
-
res["X-PathInfo"].
|
175
|
-
res["X-ScriptName"].
|
173
|
+
res.must_be :ok?
|
174
|
+
res["X-Position"].must_equal "foo"
|
175
|
+
res["X-PathInfo"].must_equal ""
|
176
|
+
res["X-ScriptName"].must_equal "/foo"
|
176
177
|
|
177
178
|
res = Rack::MockRequest.new(map).get("/bar")
|
178
|
-
res.
|
179
|
-
res["X-Position"].
|
180
|
-
res["X-PathInfo"].
|
181
|
-
res["X-ScriptName"].
|
179
|
+
res.must_be :ok?
|
180
|
+
res["X-Position"].must_equal "root"
|
181
|
+
res["X-PathInfo"].must_equal "/bar"
|
182
|
+
res["X-ScriptName"].must_equal ""
|
182
183
|
|
183
184
|
res = Rack::MockRequest.new(map).get("")
|
184
|
-
res.
|
185
|
-
res["X-Position"].
|
186
|
-
res["X-PathInfo"].
|
187
|
-
res["X-ScriptName"].
|
185
|
+
res.must_be :ok?
|
186
|
+
res["X-Position"].must_equal "root"
|
187
|
+
res["X-PathInfo"].must_equal "/"
|
188
|
+
res["X-ScriptName"].must_equal ""
|
188
189
|
end
|
189
190
|
|
190
|
-
|
191
|
+
it "not squeeze slashes" do
|
191
192
|
map = Rack::Lint.new(Rack::URLMap.new("/" => lambda { |env|
|
192
193
|
[200,
|
193
194
|
{ "Content-Type" => "text/plain",
|
@@ -205,13 +206,13 @@ describe Rack::URLMap do
|
|
205
206
|
))
|
206
207
|
|
207
208
|
res = Rack::MockRequest.new(map).get("/http://example.org/bar")
|
208
|
-
res.
|
209
|
-
res["X-Position"].
|
210
|
-
res["X-PathInfo"].
|
211
|
-
res["X-ScriptName"].
|
209
|
+
res.must_be :ok?
|
210
|
+
res["X-Position"].must_equal "root"
|
211
|
+
res["X-PathInfo"].must_equal "/http://example.org/bar"
|
212
|
+
res["X-ScriptName"].must_equal ""
|
212
213
|
end
|
213
214
|
|
214
|
-
|
215
|
+
it "not be case sensitive with hosts" do
|
215
216
|
map = Rack::Lint.new(Rack::URLMap.new("http://example.org/" => lambda { |env|
|
216
217
|
[200,
|
217
218
|
{ "Content-Type" => "text/plain",
|
@@ -222,15 +223,15 @@ describe Rack::URLMap do
|
|
222
223
|
))
|
223
224
|
|
224
225
|
res = Rack::MockRequest.new(map).get("http://example.org/")
|
225
|
-
res.
|
226
|
-
res["X-Position"].
|
227
|
-
res["X-PathInfo"].
|
228
|
-
res["X-ScriptName"].
|
226
|
+
res.must_be :ok?
|
227
|
+
res["X-Position"].must_equal "root"
|
228
|
+
res["X-PathInfo"].must_equal "/"
|
229
|
+
res["X-ScriptName"].must_equal ""
|
229
230
|
|
230
231
|
res = Rack::MockRequest.new(map).get("http://EXAMPLE.ORG/")
|
231
|
-
res.
|
232
|
-
res["X-Position"].
|
233
|
-
res["X-PathInfo"].
|
234
|
-
res["X-ScriptName"].
|
232
|
+
res.must_be :ok?
|
233
|
+
res["X-Position"].must_equal "root"
|
234
|
+
res["X-PathInfo"].must_equal "/"
|
235
|
+
res["X-ScriptName"].must_equal ""
|
235
236
|
end
|
236
237
|
end
|