rack 2.0.9.3 → 2.2.6.4

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