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.

Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/{HISTORY.md → CHANGELOG.md} +214 -164
  3. data/{COPYING → MIT-LICENSE} +4 -2
  4. data/README.rdoc +79 -133
  5. data/Rakefile +25 -18
  6. data/SPEC +9 -9
  7. data/bin/rackup +1 -0
  8. data/example/lobster.ru +2 -0
  9. data/example/protectedlobster.rb +3 -1
  10. data/example/protectedlobster.ru +2 -0
  11. data/lib/rack/auth/abstract/handler.rb +3 -1
  12. data/lib/rack/auth/abstract/request.rb +2 -0
  13. data/lib/rack/auth/basic.rb +4 -1
  14. data/lib/rack/auth/digest/md5.rb +9 -7
  15. data/lib/rack/auth/digest/nonce.rb +6 -3
  16. data/lib/rack/auth/digest/params.rb +4 -2
  17. data/lib/rack/auth/digest/request.rb +2 -0
  18. data/lib/rack/body_proxy.rb +3 -6
  19. data/lib/rack/builder.rb +38 -15
  20. data/lib/rack/cascade.rb +6 -5
  21. data/lib/rack/chunked.rb +29 -6
  22. data/lib/rack/common_logger.rb +9 -11
  23. data/lib/rack/conditional_get.rb +3 -1
  24. data/lib/rack/config.rb +2 -0
  25. data/lib/rack/content_length.rb +3 -1
  26. data/lib/rack/content_type.rb +3 -1
  27. data/lib/rack/core_ext/regexp.rb +14 -0
  28. data/lib/rack/deflater.rb +28 -17
  29. data/lib/rack/directory.rb +17 -14
  30. data/lib/rack/etag.rb +3 -1
  31. data/lib/rack/events.rb +5 -3
  32. data/lib/rack/file.rb +5 -173
  33. data/lib/rack/files.rb +178 -0
  34. data/lib/rack/handler/cgi.rb +3 -1
  35. data/lib/rack/handler/fastcgi.rb +4 -2
  36. data/lib/rack/handler/lsws.rb +3 -1
  37. data/lib/rack/handler/scgi.rb +9 -6
  38. data/lib/rack/handler/thin.rb +3 -1
  39. data/lib/rack/handler/webrick.rb +4 -2
  40. data/lib/rack/handler.rb +7 -2
  41. data/lib/rack/head.rb +2 -0
  42. data/lib/rack/lint.rb +15 -12
  43. data/lib/rack/lobster.rb +7 -5
  44. data/lib/rack/lock.rb +2 -0
  45. data/lib/rack/logger.rb +2 -0
  46. data/lib/rack/media_type.rb +10 -5
  47. data/lib/rack/method_override.rb +4 -2
  48. data/lib/rack/mime.rb +9 -1
  49. data/lib/rack/mock.rb +74 -15
  50. data/lib/rack/multipart/generator.rb +6 -7
  51. data/lib/rack/multipart/parser.rb +55 -62
  52. data/lib/rack/multipart/uploaded_file.rb +2 -0
  53. data/lib/rack/multipart.rb +6 -3
  54. data/lib/rack/null_logger.rb +2 -0
  55. data/lib/rack/query_parser.rb +51 -25
  56. data/lib/rack/recursive.rb +7 -5
  57. data/lib/rack/reloader.rb +10 -4
  58. data/lib/rack/request.rb +79 -26
  59. data/lib/rack/response.rb +71 -31
  60. data/lib/rack/rewindable_input.rb +4 -2
  61. data/lib/rack/runtime.rb +4 -2
  62. data/lib/rack/sendfile.rb +15 -8
  63. data/lib/rack/server.rb +88 -16
  64. data/lib/rack/session/abstract/id.rb +40 -22
  65. data/lib/rack/session/cookie.rb +10 -9
  66. data/lib/rack/session/memcache.rb +4 -93
  67. data/lib/rack/session/pool.rb +4 -2
  68. data/lib/rack/show_exceptions.rb +15 -9
  69. data/lib/rack/show_status.rb +4 -2
  70. data/lib/rack/static.rb +15 -10
  71. data/lib/rack/tempfile_reaper.rb +2 -0
  72. data/lib/rack/urlmap.rb +11 -2
  73. data/lib/rack/utils.rb +64 -93
  74. data/lib/rack.rb +63 -60
  75. data/rack.gemspec +17 -7
  76. metadata +33 -175
  77. data/test/builder/an_underscore_app.rb +0 -5
  78. data/test/builder/anything.rb +0 -5
  79. data/test/builder/comment.ru +0 -4
  80. data/test/builder/end.ru +0 -5
  81. data/test/builder/line.ru +0 -1
  82. data/test/builder/options.ru +0 -2
  83. data/test/cgi/assets/folder/test.js +0 -1
  84. data/test/cgi/assets/fonts/font.eot +0 -1
  85. data/test/cgi/assets/images/image.png +0 -1
  86. data/test/cgi/assets/index.html +0 -1
  87. data/test/cgi/assets/javascripts/app.js +0 -1
  88. data/test/cgi/assets/stylesheets/app.css +0 -1
  89. data/test/cgi/lighttpd.conf +0 -26
  90. data/test/cgi/rackup_stub.rb +0 -6
  91. data/test/cgi/sample_rackup.ru +0 -5
  92. data/test/cgi/test +0 -9
  93. data/test/cgi/test+directory/test+file +0 -1
  94. data/test/cgi/test.fcgi +0 -9
  95. data/test/cgi/test.gz +0 -0
  96. data/test/cgi/test.ru +0 -5
  97. data/test/gemloader.rb +0 -10
  98. data/test/helper.rb +0 -34
  99. data/test/multipart/bad_robots +0 -259
  100. data/test/multipart/binary +0 -0
  101. data/test/multipart/content_type_and_no_filename +0 -6
  102. data/test/multipart/empty +0 -10
  103. data/test/multipart/fail_16384_nofile +0 -814
  104. data/test/multipart/file1.txt +0 -1
  105. data/test/multipart/filename_and_modification_param +0 -7
  106. data/test/multipart/filename_and_no_name +0 -6
  107. data/test/multipart/filename_with_encoded_words +0 -7
  108. data/test/multipart/filename_with_escaped_quotes +0 -6
  109. data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
  110. data/test/multipart/filename_with_null_byte +0 -7
  111. data/test/multipart/filename_with_percent_escaped_quotes +0 -6
  112. data/test/multipart/filename_with_single_quote +0 -7
  113. data/test/multipart/filename_with_unescaped_percentages +0 -6
  114. data/test/multipart/filename_with_unescaped_percentages2 +0 -6
  115. data/test/multipart/filename_with_unescaped_percentages3 +0 -6
  116. data/test/multipart/filename_with_unescaped_quotes +0 -6
  117. data/test/multipart/ie +0 -6
  118. data/test/multipart/invalid_character +0 -6
  119. data/test/multipart/mixed_files +0 -21
  120. data/test/multipart/nested +0 -10
  121. data/test/multipart/none +0 -9
  122. data/test/multipart/quoted +0 -15
  123. data/test/multipart/rack-logo.png +0 -0
  124. data/test/multipart/semicolon +0 -6
  125. data/test/multipart/text +0 -15
  126. data/test/multipart/three_files_three_fields +0 -31
  127. data/test/multipart/unity3d_wwwform +0 -11
  128. data/test/multipart/webkit +0 -32
  129. data/test/rackup/config.ru +0 -31
  130. data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
  131. data/test/spec_auth_basic.rb +0 -89
  132. data/test/spec_auth_digest.rb +0 -260
  133. data/test/spec_body_proxy.rb +0 -85
  134. data/test/spec_builder.rb +0 -233
  135. data/test/spec_cascade.rb +0 -63
  136. data/test/spec_cgi.rb +0 -84
  137. data/test/spec_chunked.rb +0 -103
  138. data/test/spec_common_logger.rb +0 -107
  139. data/test/spec_conditional_get.rb +0 -103
  140. data/test/spec_config.rb +0 -23
  141. data/test/spec_content_length.rb +0 -86
  142. data/test/spec_content_type.rb +0 -46
  143. data/test/spec_deflater.rb +0 -375
  144. data/test/spec_directory.rb +0 -148
  145. data/test/spec_etag.rb +0 -108
  146. data/test/spec_events.rb +0 -133
  147. data/test/spec_fastcgi.rb +0 -85
  148. data/test/spec_file.rb +0 -264
  149. data/test/spec_handler.rb +0 -57
  150. data/test/spec_head.rb +0 -46
  151. data/test/spec_lint.rb +0 -520
  152. data/test/spec_lobster.rb +0 -59
  153. data/test/spec_lock.rb +0 -204
  154. data/test/spec_logger.rb +0 -24
  155. data/test/spec_media_type.rb +0 -42
  156. data/test/spec_method_override.rb +0 -110
  157. data/test/spec_mime.rb +0 -51
  158. data/test/spec_mock.rb +0 -359
  159. data/test/spec_multipart.rb +0 -721
  160. data/test/spec_null_logger.rb +0 -21
  161. data/test/spec_recursive.rb +0 -75
  162. data/test/spec_request.rb +0 -1423
  163. data/test/spec_response.rb +0 -528
  164. data/test/spec_rewindable_input.rb +0 -128
  165. data/test/spec_runtime.rb +0 -50
  166. data/test/spec_sendfile.rb +0 -125
  167. data/test/spec_server.rb +0 -193
  168. data/test/spec_session_abstract_id.rb +0 -31
  169. data/test/spec_session_abstract_session_hash.rb +0 -45
  170. data/test/spec_session_cookie.rb +0 -442
  171. data/test/spec_session_memcache.rb +0 -357
  172. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  173. data/test/spec_session_pool.rb +0 -247
  174. data/test/spec_show_exceptions.rb +0 -93
  175. data/test/spec_show_status.rb +0 -104
  176. data/test/spec_static.rb +0 -184
  177. data/test/spec_tempfile_reaper.rb +0 -64
  178. data/test/spec_thin.rb +0 -96
  179. data/test/spec_urlmap.rb +0 -237
  180. data/test/spec_utils.rb +0 -742
  181. data/test/spec_version.rb +0 -11
  182. data/test/spec_webrick.rb +0 -206
  183. data/test/static/another/index.html +0 -1
  184. data/test/static/foo.html +0 -1
  185. data/test/static/index.html +0 -1
  186. data/test/testrequest.rb +0 -78
  187. data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
  188. 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