rack 1.6.13 → 2.1.4.3

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/CHANGELOG.md +92 -0
  3. data/{COPYING → MIT-LICENSE} +4 -2
  4. data/README.rdoc +105 -141
  5. data/Rakefile +27 -28
  6. data/SPEC +6 -7
  7. data/bin/rackup +1 -0
  8. data/contrib/rack_logo.svg +164 -111
  9. data/example/lobster.ru +2 -0
  10. data/example/protectedlobster.rb +4 -2
  11. data/example/protectedlobster.ru +3 -1
  12. data/lib/rack/auth/abstract/handler.rb +3 -1
  13. data/lib/rack/auth/abstract/request.rb +7 -1
  14. data/lib/rack/auth/basic.rb +4 -1
  15. data/lib/rack/auth/digest/md5.rb +9 -7
  16. data/lib/rack/auth/digest/nonce.rb +6 -3
  17. data/lib/rack/auth/digest/params.rb +5 -4
  18. data/lib/rack/auth/digest/request.rb +3 -1
  19. data/lib/rack/body_proxy.rb +11 -9
  20. data/lib/rack/builder.rb +42 -18
  21. data/lib/rack/cascade.rb +6 -5
  22. data/lib/rack/chunked.rb +33 -10
  23. data/lib/rack/{commonlogger.rb → common_logger.rb} +14 -10
  24. data/lib/rack/{conditionalget.rb → conditional_get.rb} +3 -1
  25. data/lib/rack/config.rb +2 -0
  26. data/lib/rack/content_length.rb +5 -3
  27. data/lib/rack/content_type.rb +3 -1
  28. data/lib/rack/core_ext/regexp.rb +14 -0
  29. data/lib/rack/deflater.rb +33 -53
  30. data/lib/rack/directory.rb +75 -60
  31. data/lib/rack/etag.rb +8 -5
  32. data/lib/rack/events.rb +156 -0
  33. data/lib/rack/file.rb +4 -149
  34. data/lib/rack/files.rb +178 -0
  35. data/lib/rack/handler/cgi.rb +18 -17
  36. data/lib/rack/handler/fastcgi.rb +17 -16
  37. data/lib/rack/handler/lsws.rb +14 -12
  38. data/lib/rack/handler/scgi.rb +22 -19
  39. data/lib/rack/handler/thin.rb +6 -1
  40. data/lib/rack/handler/webrick.rb +28 -28
  41. data/lib/rack/handler.rb +9 -26
  42. data/lib/rack/head.rb +17 -17
  43. data/lib/rack/lint.rb +55 -52
  44. data/lib/rack/lobster.rb +8 -6
  45. data/lib/rack/lock.rb +17 -10
  46. data/lib/rack/logger.rb +4 -2
  47. data/lib/rack/media_type.rb +43 -0
  48. data/lib/rack/{methodoverride.rb → method_override.rb} +10 -8
  49. data/lib/rack/mime.rb +27 -6
  50. data/lib/rack/mock.rb +101 -60
  51. data/lib/rack/multipart/generator.rb +11 -12
  52. data/lib/rack/multipart/parser.rb +292 -161
  53. data/lib/rack/multipart/uploaded_file.rb +3 -2
  54. data/lib/rack/multipart.rb +38 -8
  55. data/lib/rack/{nulllogger.rb → null_logger.rb} +3 -1
  56. data/lib/rack/query_parser.rb +218 -0
  57. data/lib/rack/recursive.rb +11 -9
  58. data/lib/rack/reloader.rb +10 -4
  59. data/lib/rack/request.rb +447 -305
  60. data/lib/rack/response.rb +196 -83
  61. data/lib/rack/rewindable_input.rb +5 -14
  62. data/lib/rack/runtime.rb +12 -18
  63. data/lib/rack/sendfile.rb +19 -14
  64. data/lib/rack/server.rb +118 -41
  65. data/lib/rack/session/abstract/id.rb +139 -94
  66. data/lib/rack/session/cookie.rb +34 -26
  67. data/lib/rack/session/memcache.rb +4 -93
  68. data/lib/rack/session/pool.rb +12 -10
  69. data/lib/rack/show_exceptions.rb +392 -0
  70. data/lib/rack/{showstatus.rb → show_status.rb} +7 -5
  71. data/lib/rack/static.rb +41 -11
  72. data/lib/rack/tempfile_reaper.rb +4 -2
  73. data/lib/rack/urlmap.rb +25 -15
  74. data/lib/rack/utils.rb +203 -277
  75. data/lib/rack.rb +76 -24
  76. data/rack.gemspec +25 -14
  77. metadata +62 -183
  78. data/HISTORY.md +0 -375
  79. data/KNOWN-ISSUES +0 -44
  80. data/lib/rack/backports/uri/common_18.rb +0 -56
  81. data/lib/rack/backports/uri/common_192.rb +0 -52
  82. data/lib/rack/backports/uri/common_193.rb +0 -29
  83. data/lib/rack/handler/evented_mongrel.rb +0 -8
  84. data/lib/rack/handler/mongrel.rb +0 -106
  85. data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
  86. data/lib/rack/showexceptions.rb +0 -387
  87. data/lib/rack/utils/okjson.rb +0 -600
  88. data/test/builder/anything.rb +0 -5
  89. data/test/builder/comment.ru +0 -4
  90. data/test/builder/end.ru +0 -5
  91. data/test/builder/line.ru +0 -1
  92. data/test/builder/options.ru +0 -2
  93. data/test/cgi/assets/folder/test.js +0 -1
  94. data/test/cgi/assets/fonts/font.eot +0 -1
  95. data/test/cgi/assets/images/image.png +0 -1
  96. data/test/cgi/assets/index.html +0 -1
  97. data/test/cgi/assets/javascripts/app.js +0 -1
  98. data/test/cgi/assets/stylesheets/app.css +0 -1
  99. data/test/cgi/lighttpd.conf +0 -26
  100. data/test/cgi/rackup_stub.rb +0 -6
  101. data/test/cgi/sample_rackup.ru +0 -5
  102. data/test/cgi/test +0 -9
  103. data/test/cgi/test+directory/test+file +0 -1
  104. data/test/cgi/test.fcgi +0 -8
  105. data/test/cgi/test.ru +0 -5
  106. data/test/gemloader.rb +0 -10
  107. data/test/multipart/bad_robots +0 -259
  108. data/test/multipart/binary +0 -0
  109. data/test/multipart/content_type_and_no_filename +0 -6
  110. data/test/multipart/empty +0 -10
  111. data/test/multipart/fail_16384_nofile +0 -814
  112. data/test/multipart/file1.txt +0 -1
  113. data/test/multipart/filename_and_modification_param +0 -7
  114. data/test/multipart/filename_and_no_name +0 -6
  115. data/test/multipart/filename_with_escaped_quotes +0 -6
  116. data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
  117. data/test/multipart/filename_with_null_byte +0 -7
  118. data/test/multipart/filename_with_percent_escaped_quotes +0 -6
  119. data/test/multipart/filename_with_unescaped_percentages +0 -6
  120. data/test/multipart/filename_with_unescaped_percentages2 +0 -6
  121. data/test/multipart/filename_with_unescaped_percentages3 +0 -6
  122. data/test/multipart/filename_with_unescaped_quotes +0 -6
  123. data/test/multipart/ie +0 -6
  124. data/test/multipart/invalid_character +0 -6
  125. data/test/multipart/mixed_files +0 -21
  126. data/test/multipart/nested +0 -10
  127. data/test/multipart/none +0 -9
  128. data/test/multipart/semicolon +0 -6
  129. data/test/multipart/text +0 -15
  130. data/test/multipart/three_files_three_fields +0 -31
  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 -81
  135. data/test/spec_auth_digest.rb +0 -259
  136. data/test/spec_body_proxy.rb +0 -85
  137. data/test/spec_builder.rb +0 -223
  138. data/test/spec_cascade.rb +0 -61
  139. data/test/spec_cgi.rb +0 -102
  140. data/test/spec_chunked.rb +0 -101
  141. data/test/spec_commonlogger.rb +0 -93
  142. data/test/spec_conditionalget.rb +0 -102
  143. data/test/spec_config.rb +0 -22
  144. data/test/spec_content_length.rb +0 -85
  145. data/test/spec_content_type.rb +0 -45
  146. data/test/spec_deflater.rb +0 -339
  147. data/test/spec_directory.rb +0 -88
  148. data/test/spec_etag.rb +0 -107
  149. data/test/spec_fastcgi.rb +0 -107
  150. data/test/spec_file.rb +0 -221
  151. data/test/spec_handler.rb +0 -72
  152. data/test/spec_head.rb +0 -45
  153. data/test/spec_lint.rb +0 -550
  154. data/test/spec_lobster.rb +0 -58
  155. data/test/spec_lock.rb +0 -164
  156. data/test/spec_logger.rb +0 -23
  157. data/test/spec_methodoverride.rb +0 -111
  158. data/test/spec_mime.rb +0 -51
  159. data/test/spec_mock.rb +0 -297
  160. data/test/spec_mongrel.rb +0 -182
  161. data/test/spec_multipart.rb +0 -600
  162. data/test/spec_nulllogger.rb +0 -20
  163. data/test/spec_recursive.rb +0 -72
  164. data/test/spec_request.rb +0 -1232
  165. data/test/spec_response.rb +0 -407
  166. data/test/spec_rewindable_input.rb +0 -118
  167. data/test/spec_runtime.rb +0 -49
  168. data/test/spec_sendfile.rb +0 -130
  169. data/test/spec_server.rb +0 -167
  170. data/test/spec_session_abstract_id.rb +0 -53
  171. data/test/spec_session_cookie.rb +0 -410
  172. data/test/spec_session_memcache.rb +0 -358
  173. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  174. data/test/spec_session_pool.rb +0 -246
  175. data/test/spec_showexceptions.rb +0 -98
  176. data/test/spec_showstatus.rb +0 -103
  177. data/test/spec_static.rb +0 -145
  178. data/test/spec_tempfile_reaper.rb +0 -63
  179. data/test/spec_thin.rb +0 -91
  180. data/test/spec_urlmap.rb +0 -236
  181. data/test/spec_utils.rb +0 -647
  182. data/test/spec_version.rb +0 -17
  183. data/test/spec_webrick.rb +0 -184
  184. data/test/static/another/index.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_mongrel.rb DELETED
@@ -1,182 +0,0 @@
1
- begin
2
- require 'rack'
3
- require 'rack/handler/mongrel'
4
- require File.expand_path('../testrequest', __FILE__)
5
- require 'timeout'
6
-
7
- Thread.abort_on_exception = true
8
- $tcp_defer_accept_opts = nil
9
- $tcp_cork_opts = nil
10
-
11
- describe Rack::Handler::Mongrel do
12
- extend TestRequest::Helpers
13
-
14
- @server = Mongrel::HttpServer.new(@host='127.0.0.1', @port=9201)
15
- @server.register('/test',
16
- Rack::Handler::Mongrel.new(Rack::Lint.new(TestRequest.new)))
17
- @server.register('/stream',
18
- Rack::Handler::Mongrel.new(Rack::Lint.new(StreamingRequest)))
19
- @acc = @server.run
20
-
21
- should "respond" do
22
- lambda {
23
- GET("/test")
24
- }.should.not.raise
25
- end
26
-
27
- should "be a Mongrel" do
28
- GET("/test")
29
- status.should.equal 200
30
- response["SERVER_SOFTWARE"].should =~ /Mongrel/
31
- response["HTTP_VERSION"].should.equal "HTTP/1.1"
32
- response["SERVER_PROTOCOL"].should.equal "HTTP/1.1"
33
- response["SERVER_PORT"].should.equal "9201"
34
- response["SERVER_NAME"].should.equal "127.0.0.1"
35
- end
36
-
37
- should "have rack headers" do
38
- GET("/test")
39
- response["rack.version"].should.equal [1,3]
40
- response["rack.multithread"].should.be.true
41
- response["rack.multiprocess"].should.be.false
42
- response["rack.run_once"].should.be.false
43
- end
44
-
45
- should "have CGI headers on GET" do
46
- GET("/test")
47
- response["REQUEST_METHOD"].should.equal "GET"
48
- response["SCRIPT_NAME"].should.equal "/test"
49
- response["REQUEST_PATH"].should.equal "/test"
50
- response["PATH_INFO"].should.be.equal ""
51
- response["QUERY_STRING"].should.equal ""
52
- response["test.postdata"].should.equal ""
53
-
54
- GET("/test/foo?quux=1")
55
- response["REQUEST_METHOD"].should.equal "GET"
56
- response["SCRIPT_NAME"].should.equal "/test"
57
- response["REQUEST_PATH"].should.equal "/test/foo"
58
- response["PATH_INFO"].should.equal "/foo"
59
- response["QUERY_STRING"].should.equal "quux=1"
60
- end
61
-
62
- should "have CGI headers on POST" do
63
- POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'})
64
- status.should.equal 200
65
- response["REQUEST_METHOD"].should.equal "POST"
66
- response["SCRIPT_NAME"].should.equal "/test"
67
- response["REQUEST_PATH"].should.equal "/test"
68
- response["QUERY_STRING"].should.equal ""
69
- response["HTTP_X_TEST_HEADER"].should.equal "42"
70
- response["test.postdata"].should.equal "rack-form-data=23"
71
- end
72
-
73
- should "support HTTP auth" do
74
- GET("/test", {:user => "ruth", :passwd => "secret"})
75
- response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ="
76
- end
77
-
78
- should "set status" do
79
- GET("/test?secret")
80
- status.should.equal 403
81
- response["rack.url_scheme"].should.equal "http"
82
- end
83
-
84
- should "provide a .run" do
85
- block_ran = false
86
- Thread.new {
87
- Rack::Handler::Mongrel.run(lambda {}, {:Host => '127.0.0.1', :Port => 9211}) { |server|
88
- server.should.be.kind_of Mongrel::HttpServer
89
- block_ran = true
90
- }
91
- }
92
- sleep 1
93
- block_ran.should.be.true
94
- end
95
-
96
- should "provide a .run that maps a hash" do
97
- block_ran = false
98
- Thread.new {
99
- map = {'/'=>lambda{},'/foo'=>lambda{}}
100
- Rack::Handler::Mongrel.run(map, :map => true, :Host => '127.0.0.1', :Port => 9221) { |server|
101
- server.should.be.kind_of Mongrel::HttpServer
102
- server.classifier.uris.size.should.equal 2
103
- server.classifier.uris.should.not.include '/arf'
104
- server.classifier.uris.should.include '/'
105
- server.classifier.uris.should.include '/foo'
106
- block_ran = true
107
- }
108
- }
109
- sleep 1
110
- block_ran.should.be.true
111
- end
112
-
113
- should "provide a .run that maps a urlmap" do
114
- block_ran = false
115
- Thread.new {
116
- map = Rack::URLMap.new({'/'=>lambda{},'/bar'=>lambda{}})
117
- Rack::Handler::Mongrel.run(map, {:map => true, :Host => '127.0.0.1', :Port => 9231}) { |server|
118
- server.should.be.kind_of Mongrel::HttpServer
119
- server.classifier.uris.size.should.equal 2
120
- server.classifier.uris.should.not.include '/arf'
121
- server.classifier.uris.should.include '/'
122
- server.classifier.uris.should.include '/bar'
123
- block_ran = true
124
- }
125
- }
126
- sleep 1
127
- block_ran.should.be.true
128
- end
129
-
130
- should "provide a .run that maps a urlmap restricting by host" do
131
- block_ran = false
132
- Thread.new {
133
- map = Rack::URLMap.new({
134
- '/' => lambda{},
135
- '/foo' => lambda{},
136
- '/bar' => lambda{},
137
- 'http://127.0.0.1/' => lambda{},
138
- 'http://127.0.0.1/bar' => lambda{},
139
- 'http://falsehost/arf' => lambda{},
140
- 'http://falsehost/qux' => lambda{}
141
- })
142
- opt = {:map => true, :Port => 9241, :Host => '127.0.0.1'}
143
- Rack::Handler::Mongrel.run(map, opt) { |server|
144
- server.should.be.kind_of Mongrel::HttpServer
145
- server.classifier.uris.should.include '/'
146
- server.classifier.handler_map['/'].size.should.equal 2
147
- server.classifier.uris.should.include '/foo'
148
- server.classifier.handler_map['/foo'].size.should.equal 1
149
- server.classifier.uris.should.include '/bar'
150
- server.classifier.handler_map['/bar'].size.should.equal 2
151
- server.classifier.uris.should.not.include '/qux'
152
- server.classifier.uris.should.not.include '/arf'
153
- server.classifier.uris.size.should.equal 3
154
- block_ran = true
155
- }
156
- }
157
- sleep 1
158
- block_ran.should.be.true
159
- end
160
-
161
- should "stream #each part of the response" do
162
- body = ''
163
- begin
164
- Timeout.timeout(1) do
165
- Net::HTTP.start(@host, @port) do |http|
166
- get = Net::HTTP::Get.new('/stream')
167
- http.request(get) do |response|
168
- response.read_body { |part| body << part }
169
- end
170
- end
171
- end
172
- rescue Timeout::Error
173
- end
174
- body.should.not.be.empty
175
- end
176
-
177
- @acc.raise Mongrel::StopServer
178
- end
179
-
180
- rescue LoadError
181
- warn "Skipping Rack::Handler::Mongrel tests (Mongrel is required). `gem install mongrel` and try again."
182
- end