rack 2.0.9.4 → 2.1.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.
- checksums.yaml +4 -4
- data/{HISTORY.md → CHANGELOG.md} +214 -164
- data/{COPYING → MIT-LICENSE} +4 -2
- data/README.rdoc +79 -133
- data/Rakefile +25 -18
- data/SPEC +9 -9
- data/bin/rackup +1 -0
- data/example/lobster.ru +2 -0
- data/example/protectedlobster.rb +3 -1
- data/example/protectedlobster.ru +2 -0
- data/lib/rack/auth/abstract/handler.rb +3 -1
- data/lib/rack/auth/abstract/request.rb +2 -0
- data/lib/rack/auth/basic.rb +4 -1
- data/lib/rack/auth/digest/md5.rb +9 -7
- data/lib/rack/auth/digest/nonce.rb +6 -3
- data/lib/rack/auth/digest/params.rb +4 -2
- data/lib/rack/auth/digest/request.rb +2 -0
- data/lib/rack/body_proxy.rb +3 -6
- data/lib/rack/builder.rb +38 -15
- data/lib/rack/cascade.rb +6 -5
- data/lib/rack/chunked.rb +29 -6
- data/lib/rack/common_logger.rb +9 -11
- data/lib/rack/conditional_get.rb +3 -1
- data/lib/rack/config.rb +2 -0
- data/lib/rack/content_length.rb +3 -1
- data/lib/rack/content_type.rb +3 -1
- data/lib/rack/core_ext/regexp.rb +14 -0
- data/lib/rack/deflater.rb +28 -17
- data/lib/rack/directory.rb +17 -14
- data/lib/rack/etag.rb +3 -1
- data/lib/rack/events.rb +5 -3
- data/lib/rack/file.rb +5 -173
- data/lib/rack/files.rb +178 -0
- data/lib/rack/handler/cgi.rb +3 -1
- data/lib/rack/handler/fastcgi.rb +4 -2
- data/lib/rack/handler/lsws.rb +3 -1
- data/lib/rack/handler/scgi.rb +9 -6
- data/lib/rack/handler/thin.rb +3 -1
- data/lib/rack/handler/webrick.rb +4 -2
- data/lib/rack/handler.rb +7 -2
- data/lib/rack/head.rb +2 -0
- data/lib/rack/lint.rb +15 -12
- data/lib/rack/lobster.rb +7 -5
- data/lib/rack/lock.rb +2 -0
- data/lib/rack/logger.rb +2 -0
- data/lib/rack/media_type.rb +10 -5
- data/lib/rack/method_override.rb +4 -2
- data/lib/rack/mime.rb +9 -1
- data/lib/rack/mock.rb +74 -15
- data/lib/rack/multipart/generator.rb +6 -7
- data/lib/rack/multipart/parser.rb +55 -62
- data/lib/rack/multipart/uploaded_file.rb +2 -0
- data/lib/rack/multipart.rb +6 -3
- data/lib/rack/null_logger.rb +2 -0
- data/lib/rack/query_parser.rb +51 -25
- data/lib/rack/recursive.rb +7 -5
- data/lib/rack/reloader.rb +10 -4
- data/lib/rack/request.rb +79 -26
- data/lib/rack/response.rb +71 -31
- data/lib/rack/rewindable_input.rb +4 -2
- data/lib/rack/runtime.rb +4 -2
- data/lib/rack/sendfile.rb +15 -8
- data/lib/rack/server.rb +88 -16
- data/lib/rack/session/abstract/id.rb +40 -22
- data/lib/rack/session/cookie.rb +10 -9
- data/lib/rack/session/memcache.rb +4 -93
- data/lib/rack/session/pool.rb +4 -2
- data/lib/rack/show_exceptions.rb +15 -9
- data/lib/rack/show_status.rb +4 -2
- data/lib/rack/static.rb +15 -10
- data/lib/rack/tempfile_reaper.rb +2 -0
- data/lib/rack/urlmap.rb +11 -2
- data/lib/rack/utils.rb +64 -93
- data/lib/rack.rb +63 -60
- data/rack.gemspec +17 -7
- metadata +33 -175
- data/test/builder/an_underscore_app.rb +0 -5
- data/test/builder/anything.rb +0 -5
- data/test/builder/comment.ru +0 -4
- data/test/builder/end.ru +0 -5
- data/test/builder/line.ru +0 -1
- data/test/builder/options.ru +0 -2
- data/test/cgi/assets/folder/test.js +0 -1
- data/test/cgi/assets/fonts/font.eot +0 -1
- data/test/cgi/assets/images/image.png +0 -1
- data/test/cgi/assets/index.html +0 -1
- data/test/cgi/assets/javascripts/app.js +0 -1
- data/test/cgi/assets/stylesheets/app.css +0 -1
- data/test/cgi/lighttpd.conf +0 -26
- data/test/cgi/rackup_stub.rb +0 -6
- data/test/cgi/sample_rackup.ru +0 -5
- data/test/cgi/test +0 -9
- data/test/cgi/test+directory/test+file +0 -1
- data/test/cgi/test.fcgi +0 -9
- data/test/cgi/test.gz +0 -0
- data/test/cgi/test.ru +0 -5
- data/test/gemloader.rb +0 -10
- data/test/helper.rb +0 -34
- data/test/multipart/bad_robots +0 -259
- data/test/multipart/binary +0 -0
- data/test/multipart/content_type_and_no_filename +0 -6
- data/test/multipart/empty +0 -10
- data/test/multipart/fail_16384_nofile +0 -814
- data/test/multipart/file1.txt +0 -1
- data/test/multipart/filename_and_modification_param +0 -7
- data/test/multipart/filename_and_no_name +0 -6
- data/test/multipart/filename_with_encoded_words +0 -7
- data/test/multipart/filename_with_escaped_quotes +0 -6
- data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
- data/test/multipart/filename_with_null_byte +0 -7
- data/test/multipart/filename_with_percent_escaped_quotes +0 -6
- data/test/multipart/filename_with_single_quote +0 -7
- data/test/multipart/filename_with_unescaped_percentages +0 -6
- data/test/multipart/filename_with_unescaped_percentages2 +0 -6
- data/test/multipart/filename_with_unescaped_percentages3 +0 -6
- data/test/multipart/filename_with_unescaped_quotes +0 -6
- data/test/multipart/ie +0 -6
- data/test/multipart/invalid_character +0 -6
- data/test/multipart/mixed_files +0 -21
- data/test/multipart/nested +0 -10
- data/test/multipart/none +0 -9
- data/test/multipart/quoted +0 -15
- data/test/multipart/rack-logo.png +0 -0
- data/test/multipart/semicolon +0 -6
- data/test/multipart/text +0 -15
- data/test/multipart/three_files_three_fields +0 -31
- data/test/multipart/unity3d_wwwform +0 -11
- data/test/multipart/webkit +0 -32
- data/test/rackup/config.ru +0 -31
- data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
- data/test/spec_auth_basic.rb +0 -89
- data/test/spec_auth_digest.rb +0 -260
- data/test/spec_body_proxy.rb +0 -85
- data/test/spec_builder.rb +0 -233
- data/test/spec_cascade.rb +0 -63
- data/test/spec_cgi.rb +0 -84
- data/test/spec_chunked.rb +0 -103
- data/test/spec_common_logger.rb +0 -107
- data/test/spec_conditional_get.rb +0 -103
- data/test/spec_config.rb +0 -23
- data/test/spec_content_length.rb +0 -86
- data/test/spec_content_type.rb +0 -46
- data/test/spec_deflater.rb +0 -375
- data/test/spec_directory.rb +0 -148
- data/test/spec_etag.rb +0 -108
- data/test/spec_events.rb +0 -133
- data/test/spec_fastcgi.rb +0 -85
- data/test/spec_file.rb +0 -264
- data/test/spec_handler.rb +0 -57
- data/test/spec_head.rb +0 -46
- data/test/spec_lint.rb +0 -520
- data/test/spec_lobster.rb +0 -59
- data/test/spec_lock.rb +0 -204
- data/test/spec_logger.rb +0 -24
- data/test/spec_media_type.rb +0 -42
- data/test/spec_method_override.rb +0 -110
- data/test/spec_mime.rb +0 -51
- data/test/spec_mock.rb +0 -359
- data/test/spec_multipart.rb +0 -721
- data/test/spec_null_logger.rb +0 -21
- data/test/spec_recursive.rb +0 -75
- data/test/spec_request.rb +0 -1423
- data/test/spec_response.rb +0 -528
- data/test/spec_rewindable_input.rb +0 -128
- data/test/spec_runtime.rb +0 -50
- data/test/spec_sendfile.rb +0 -125
- data/test/spec_server.rb +0 -193
- data/test/spec_session_abstract_id.rb +0 -31
- data/test/spec_session_abstract_session_hash.rb +0 -45
- data/test/spec_session_cookie.rb +0 -442
- data/test/spec_session_memcache.rb +0 -357
- data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
- data/test/spec_session_pool.rb +0 -247
- data/test/spec_show_exceptions.rb +0 -93
- data/test/spec_show_status.rb +0 -104
- data/test/spec_static.rb +0 -184
- data/test/spec_tempfile_reaper.rb +0 -64
- data/test/spec_thin.rb +0 -96
- data/test/spec_urlmap.rb +0 -237
- data/test/spec_utils.rb +0 -742
- data/test/spec_version.rb +0 -11
- data/test/spec_webrick.rb +0 -206
- data/test/static/another/index.html +0 -1
- data/test/static/foo.html +0 -1
- data/test/static/index.html +0 -1
- data/test/testrequest.rb +0 -78
- data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
- data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
data/test/spec_urlmap.rb
DELETED
@@ -1,237 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'rack/urlmap'
|
3
|
-
require 'rack/mock'
|
4
|
-
|
5
|
-
describe Rack::URLMap do
|
6
|
-
it "dispatches paths correctly" do
|
7
|
-
app = lambda { |env|
|
8
|
-
[200, {
|
9
|
-
'X-ScriptName' => env['SCRIPT_NAME'],
|
10
|
-
'X-PathInfo' => env['PATH_INFO'],
|
11
|
-
'Content-Type' => 'text/plain'
|
12
|
-
}, [""]]
|
13
|
-
}
|
14
|
-
map = Rack::Lint.new(Rack::URLMap.new({
|
15
|
-
'http://foo.org/bar' => app,
|
16
|
-
'/foo' => app,
|
17
|
-
'/foo/bar' => app
|
18
|
-
}))
|
19
|
-
|
20
|
-
res = Rack::MockRequest.new(map).get("/")
|
21
|
-
res.must_be :not_found?
|
22
|
-
|
23
|
-
res = Rack::MockRequest.new(map).get("/qux")
|
24
|
-
res.must_be :not_found?
|
25
|
-
|
26
|
-
res = Rack::MockRequest.new(map).get("/foo")
|
27
|
-
res.must_be :ok?
|
28
|
-
res["X-ScriptName"].must_equal "/foo"
|
29
|
-
res["X-PathInfo"].must_equal ""
|
30
|
-
|
31
|
-
res = Rack::MockRequest.new(map).get("/foo/")
|
32
|
-
res.must_be :ok?
|
33
|
-
res["X-ScriptName"].must_equal "/foo"
|
34
|
-
res["X-PathInfo"].must_equal "/"
|
35
|
-
|
36
|
-
res = Rack::MockRequest.new(map).get("/foo/bar")
|
37
|
-
res.must_be :ok?
|
38
|
-
res["X-ScriptName"].must_equal "/foo/bar"
|
39
|
-
res["X-PathInfo"].must_equal ""
|
40
|
-
|
41
|
-
res = Rack::MockRequest.new(map).get("/foo/bar/")
|
42
|
-
res.must_be :ok?
|
43
|
-
res["X-ScriptName"].must_equal "/foo/bar"
|
44
|
-
res["X-PathInfo"].must_equal "/"
|
45
|
-
|
46
|
-
res = Rack::MockRequest.new(map).get("/foo///bar//quux")
|
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"
|
51
|
-
|
52
|
-
res = Rack::MockRequest.new(map).get("/foo/quux", "SCRIPT_NAME" => "/bleh")
|
53
|
-
res.must_be :ok?
|
54
|
-
res["X-ScriptName"].must_equal "/bleh/foo"
|
55
|
-
res["X-PathInfo"].must_equal "/quux"
|
56
|
-
|
57
|
-
res = Rack::MockRequest.new(map).get("/bar", 'HTTP_HOST' => 'foo.org')
|
58
|
-
res.must_be :ok?
|
59
|
-
res["X-ScriptName"].must_equal "/bar"
|
60
|
-
res["X-PathInfo"].must_be :empty?
|
61
|
-
|
62
|
-
res = Rack::MockRequest.new(map).get("/bar/", 'HTTP_HOST' => 'foo.org')
|
63
|
-
res.must_be :ok?
|
64
|
-
res["X-ScriptName"].must_equal "/bar"
|
65
|
-
res["X-PathInfo"].must_equal '/'
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
it "dispatches hosts correctly" do
|
70
|
-
map = Rack::Lint.new(Rack::URLMap.new("http://foo.org/" => lambda { |env|
|
71
|
-
[200,
|
72
|
-
{ "Content-Type" => "text/plain",
|
73
|
-
"X-Position" => "foo.org",
|
74
|
-
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
|
75
|
-
}, [""]]},
|
76
|
-
"http://subdomain.foo.org/" => lambda { |env|
|
77
|
-
[200,
|
78
|
-
{ "Content-Type" => "text/plain",
|
79
|
-
"X-Position" => "subdomain.foo.org",
|
80
|
-
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
|
81
|
-
}, [""]]},
|
82
|
-
"http://bar.org/" => lambda { |env|
|
83
|
-
[200,
|
84
|
-
{ "Content-Type" => "text/plain",
|
85
|
-
"X-Position" => "bar.org",
|
86
|
-
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
|
87
|
-
}, [""]]},
|
88
|
-
"/" => lambda { |env|
|
89
|
-
[200,
|
90
|
-
{ "Content-Type" => "text/plain",
|
91
|
-
"X-Position" => "default.org",
|
92
|
-
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
|
93
|
-
}, [""]]}
|
94
|
-
))
|
95
|
-
|
96
|
-
res = Rack::MockRequest.new(map).get("/")
|
97
|
-
res.must_be :ok?
|
98
|
-
res["X-Position"].must_equal "default.org"
|
99
|
-
|
100
|
-
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "bar.org")
|
101
|
-
res.must_be :ok?
|
102
|
-
res["X-Position"].must_equal "bar.org"
|
103
|
-
|
104
|
-
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "foo.org")
|
105
|
-
res.must_be :ok?
|
106
|
-
res["X-Position"].must_equal "foo.org"
|
107
|
-
|
108
|
-
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "subdomain.foo.org", "SERVER_NAME" => "foo.org")
|
109
|
-
res.must_be :ok?
|
110
|
-
res["X-Position"].must_equal "subdomain.foo.org"
|
111
|
-
|
112
|
-
res = Rack::MockRequest.new(map).get("http://foo.org/")
|
113
|
-
res.must_be :ok?
|
114
|
-
res["X-Position"].must_equal "foo.org"
|
115
|
-
|
116
|
-
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org")
|
117
|
-
res.must_be :ok?
|
118
|
-
res["X-Position"].must_equal "default.org"
|
119
|
-
|
120
|
-
res = Rack::MockRequest.new(map).get("/",
|
121
|
-
"HTTP_HOST" => "example.org:9292",
|
122
|
-
"SERVER_PORT" => "9292")
|
123
|
-
res.must_be :ok?
|
124
|
-
res["X-Position"].must_equal "default.org"
|
125
|
-
end
|
126
|
-
|
127
|
-
it "be nestable" do
|
128
|
-
map = Rack::Lint.new(Rack::URLMap.new("/foo" =>
|
129
|
-
Rack::URLMap.new("/bar" =>
|
130
|
-
Rack::URLMap.new("/quux" => lambda { |env|
|
131
|
-
[200,
|
132
|
-
{ "Content-Type" => "text/plain",
|
133
|
-
"X-Position" => "/foo/bar/quux",
|
134
|
-
"X-PathInfo" => env["PATH_INFO"],
|
135
|
-
"X-ScriptName" => env["SCRIPT_NAME"],
|
136
|
-
}, [""]]}
|
137
|
-
))))
|
138
|
-
|
139
|
-
res = Rack::MockRequest.new(map).get("/foo/bar")
|
140
|
-
res.must_be :not_found?
|
141
|
-
|
142
|
-
res = Rack::MockRequest.new(map).get("/foo/bar/quux")
|
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"
|
147
|
-
end
|
148
|
-
|
149
|
-
it "route root apps correctly" do
|
150
|
-
map = Rack::Lint.new(Rack::URLMap.new("/" => lambda { |env|
|
151
|
-
[200,
|
152
|
-
{ "Content-Type" => "text/plain",
|
153
|
-
"X-Position" => "root",
|
154
|
-
"X-PathInfo" => env["PATH_INFO"],
|
155
|
-
"X-ScriptName" => env["SCRIPT_NAME"]
|
156
|
-
}, [""]]},
|
157
|
-
"/foo" => lambda { |env|
|
158
|
-
[200,
|
159
|
-
{ "Content-Type" => "text/plain",
|
160
|
-
"X-Position" => "foo",
|
161
|
-
"X-PathInfo" => env["PATH_INFO"],
|
162
|
-
"X-ScriptName" => env["SCRIPT_NAME"]
|
163
|
-
}, [""]]}
|
164
|
-
))
|
165
|
-
|
166
|
-
res = Rack::MockRequest.new(map).get("/foo/bar")
|
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"
|
171
|
-
|
172
|
-
res = Rack::MockRequest.new(map).get("/foo")
|
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"
|
177
|
-
|
178
|
-
res = Rack::MockRequest.new(map).get("/bar")
|
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 ""
|
183
|
-
|
184
|
-
res = Rack::MockRequest.new(map).get("")
|
185
|
-
res.must_be :ok?
|
186
|
-
res["X-Position"].must_equal "root"
|
187
|
-
res["X-PathInfo"].must_equal "/"
|
188
|
-
res["X-ScriptName"].must_equal ""
|
189
|
-
end
|
190
|
-
|
191
|
-
it "not squeeze slashes" do
|
192
|
-
map = Rack::Lint.new(Rack::URLMap.new("/" => lambda { |env|
|
193
|
-
[200,
|
194
|
-
{ "Content-Type" => "text/plain",
|
195
|
-
"X-Position" => "root",
|
196
|
-
"X-PathInfo" => env["PATH_INFO"],
|
197
|
-
"X-ScriptName" => env["SCRIPT_NAME"]
|
198
|
-
}, [""]]},
|
199
|
-
"/foo" => lambda { |env|
|
200
|
-
[200,
|
201
|
-
{ "Content-Type" => "text/plain",
|
202
|
-
"X-Position" => "foo",
|
203
|
-
"X-PathInfo" => env["PATH_INFO"],
|
204
|
-
"X-ScriptName" => env["SCRIPT_NAME"]
|
205
|
-
}, [""]]}
|
206
|
-
))
|
207
|
-
|
208
|
-
res = Rack::MockRequest.new(map).get("/http://example.org/bar")
|
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 ""
|
213
|
-
end
|
214
|
-
|
215
|
-
it "not be case sensitive with hosts" do
|
216
|
-
map = Rack::Lint.new(Rack::URLMap.new("http://example.org/" => lambda { |env|
|
217
|
-
[200,
|
218
|
-
{ "Content-Type" => "text/plain",
|
219
|
-
"X-Position" => "root",
|
220
|
-
"X-PathInfo" => env["PATH_INFO"],
|
221
|
-
"X-ScriptName" => env["SCRIPT_NAME"]
|
222
|
-
}, [""]]}
|
223
|
-
))
|
224
|
-
|
225
|
-
res = Rack::MockRequest.new(map).get("http://example.org/")
|
226
|
-
res.must_be :ok?
|
227
|
-
res["X-Position"].must_equal "root"
|
228
|
-
res["X-PathInfo"].must_equal "/"
|
229
|
-
res["X-ScriptName"].must_equal ""
|
230
|
-
|
231
|
-
res = Rack::MockRequest.new(map).get("http://EXAMPLE.ORG/")
|
232
|
-
res.must_be :ok?
|
233
|
-
res["X-Position"].must_equal "root"
|
234
|
-
res["X-PathInfo"].must_equal "/"
|
235
|
-
res["X-ScriptName"].must_equal ""
|
236
|
-
end
|
237
|
-
end
|