rack 1.6.12 → 2.0.7

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 (141) hide show
  1. checksums.yaml +5 -5
  2. data/COPYING +1 -1
  3. data/HISTORY.md +138 -8
  4. data/README.rdoc +18 -28
  5. data/Rakefile +6 -14
  6. data/SPEC +10 -11
  7. data/contrib/rack_logo.svg +164 -111
  8. data/example/protectedlobster.rb +1 -1
  9. data/example/protectedlobster.ru +1 -1
  10. data/lib/rack.rb +70 -21
  11. data/lib/rack/auth/abstract/request.rb +5 -1
  12. data/lib/rack/auth/digest/params.rb +2 -3
  13. data/lib/rack/auth/digest/request.rb +1 -1
  14. data/lib/rack/body_proxy.rb +14 -9
  15. data/lib/rack/builder.rb +3 -3
  16. data/lib/rack/chunked.rb +5 -5
  17. data/lib/rack/{commonlogger.rb → common_logger.rb} +3 -3
  18. data/lib/rack/{conditionalget.rb → conditional_get.rb} +0 -0
  19. data/lib/rack/content_length.rb +2 -2
  20. data/lib/rack/deflater.rb +4 -39
  21. data/lib/rack/directory.rb +66 -54
  22. data/lib/rack/etag.rb +5 -4
  23. data/lib/rack/events.rb +154 -0
  24. data/lib/rack/file.rb +64 -40
  25. data/lib/rack/handler.rb +3 -25
  26. data/lib/rack/handler/cgi.rb +15 -16
  27. data/lib/rack/handler/fastcgi.rb +13 -14
  28. data/lib/rack/handler/lsws.rb +11 -11
  29. data/lib/rack/handler/scgi.rb +15 -15
  30. data/lib/rack/handler/thin.rb +3 -0
  31. data/lib/rack/handler/webrick.rb +24 -26
  32. data/lib/rack/head.rb +15 -17
  33. data/lib/rack/lint.rb +40 -40
  34. data/lib/rack/lobster.rb +1 -1
  35. data/lib/rack/lock.rb +15 -10
  36. data/lib/rack/logger.rb +2 -2
  37. data/lib/rack/media_type.rb +38 -0
  38. data/lib/rack/{methodoverride.rb → method_override.rb} +6 -6
  39. data/lib/rack/mime.rb +18 -5
  40. data/lib/rack/mock.rb +36 -54
  41. data/lib/rack/multipart.rb +35 -6
  42. data/lib/rack/multipart/generator.rb +5 -5
  43. data/lib/rack/multipart/parser.rb +270 -157
  44. data/lib/rack/multipart/uploaded_file.rb +1 -2
  45. data/lib/rack/{nulllogger.rb → null_logger.rb} +1 -1
  46. data/lib/rack/query_parser.rb +192 -0
  47. data/lib/rack/recursive.rb +8 -8
  48. data/lib/rack/request.rb +394 -305
  49. data/lib/rack/response.rb +130 -57
  50. data/lib/rack/rewindable_input.rb +1 -12
  51. data/lib/rack/runtime.rb +10 -18
  52. data/lib/rack/sendfile.rb +5 -7
  53. data/lib/rack/server.rb +30 -23
  54. data/lib/rack/session/abstract/id.rb +108 -138
  55. data/lib/rack/session/cookie.rb +26 -28
  56. data/lib/rack/session/memcache.rb +8 -14
  57. data/lib/rack/session/pool.rb +14 -21
  58. data/lib/rack/show_exceptions.rb +386 -0
  59. data/lib/rack/{showstatus.rb → show_status.rb} +3 -3
  60. data/lib/rack/static.rb +30 -5
  61. data/lib/rack/tempfile_reaper.rb +2 -2
  62. data/lib/rack/urlmap.rb +15 -14
  63. data/lib/rack/utils.rb +136 -211
  64. data/rack.gemspec +10 -9
  65. data/test/builder/an_underscore_app.rb +5 -0
  66. data/test/builder/options.ru +1 -1
  67. data/test/cgi/test.fcgi +1 -0
  68. data/test/cgi/test.gz +0 -0
  69. data/test/helper.rb +34 -0
  70. data/test/multipart/filename_with_encoded_words +7 -0
  71. data/test/multipart/filename_with_single_quote +7 -0
  72. data/test/multipart/quoted +15 -0
  73. data/test/multipart/rack-logo.png +0 -0
  74. data/test/multipart/unity3d_wwwform +11 -0
  75. data/test/registering_handler/rack/handler/registering_myself.rb +1 -1
  76. data/test/spec_auth_basic.rb +27 -19
  77. data/test/spec_auth_digest.rb +47 -46
  78. data/test/spec_body_proxy.rb +27 -27
  79. data/test/spec_builder.rb +51 -41
  80. data/test/spec_cascade.rb +24 -22
  81. data/test/spec_cgi.rb +49 -67
  82. data/test/spec_chunked.rb +37 -35
  83. data/test/{spec_commonlogger.rb → spec_common_logger.rb} +23 -21
  84. data/test/{spec_conditionalget.rb → spec_conditional_get.rb} +29 -28
  85. data/test/spec_config.rb +3 -2
  86. data/test/spec_content_length.rb +18 -17
  87. data/test/spec_content_type.rb +13 -12
  88. data/test/spec_deflater.rb +85 -49
  89. data/test/spec_directory.rb +87 -27
  90. data/test/spec_etag.rb +32 -31
  91. data/test/spec_events.rb +133 -0
  92. data/test/spec_fastcgi.rb +50 -72
  93. data/test/spec_file.rb +120 -77
  94. data/test/spec_handler.rb +19 -34
  95. data/test/spec_head.rb +15 -14
  96. data/test/spec_lint.rb +164 -199
  97. data/test/spec_lobster.rb +24 -23
  98. data/test/spec_lock.rb +79 -39
  99. data/test/spec_logger.rb +4 -3
  100. data/test/spec_media_type.rb +42 -0
  101. data/test/{spec_methodoverride.rb → spec_method_override.rb} +34 -35
  102. data/test/spec_mime.rb +19 -19
  103. data/test/spec_mock.rb +206 -144
  104. data/test/spec_multipart.rb +322 -200
  105. data/test/{spec_nulllogger.rb → spec_null_logger.rb} +5 -4
  106. data/test/spec_recursive.rb +17 -14
  107. data/test/spec_request.rb +780 -605
  108. data/test/spec_response.rb +215 -112
  109. data/test/spec_rewindable_input.rb +50 -40
  110. data/test/spec_runtime.rb +11 -10
  111. data/test/spec_sendfile.rb +30 -35
  112. data/test/spec_server.rb +78 -52
  113. data/test/spec_session_abstract_id.rb +11 -33
  114. data/test/spec_session_abstract_session_hash.rb +45 -0
  115. data/test/spec_session_cookie.rb +99 -67
  116. data/test/spec_session_memcache.rb +63 -101
  117. data/test/spec_session_pool.rb +48 -84
  118. data/test/{spec_showexceptions.rb → spec_show_exceptions.rb} +23 -28
  119. data/test/{spec_showstatus.rb → spec_show_status.rb} +36 -35
  120. data/test/spec_static.rb +71 -32
  121. data/test/spec_tempfile_reaper.rb +11 -10
  122. data/test/spec_thin.rb +55 -50
  123. data/test/spec_urlmap.rb +79 -78
  124. data/test/spec_utils.rb +441 -346
  125. data/test/spec_version.rb +2 -8
  126. data/test/spec_webrick.rb +93 -71
  127. data/test/static/foo.html +1 -0
  128. data/test/testrequest.rb +1 -1
  129. data/test/unregistered_handler/rack/handler/unregistered.rb +1 -1
  130. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +1 -1
  131. metadata +92 -70
  132. data/KNOWN-ISSUES +0 -44
  133. data/lib/rack/backports/uri/common_18.rb +0 -56
  134. data/lib/rack/backports/uri/common_192.rb +0 -52
  135. data/lib/rack/backports/uri/common_193.rb +0 -29
  136. data/lib/rack/handler/evented_mongrel.rb +0 -8
  137. data/lib/rack/handler/mongrel.rb +0 -106
  138. data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
  139. data/lib/rack/showexceptions.rb +0 -387
  140. data/lib/rack/utils/okjson.rb +0 -600
  141. data/test/spec_mongrel.rb +0 -182
@@ -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