rack 1.3.0.beta2 → 1.3.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.

data/README CHANGED
@@ -119,7 +119,7 @@ By default, the lobster is found at http://localhost:9292.
119
119
 
120
120
  == Installing with RubyGems
121
121
 
122
- A Gem of Rack is available at gemcutter.org. You can install it with:
122
+ A Gem of Rack is available at rubygems.org. You can install it with:
123
123
 
124
124
  gem install rack
125
125
 
@@ -317,7 +317,7 @@ run on port 11211) and memcache-client installed.
317
317
  * Security fix in Rack::Auth::Digest::MD5: when authenticator
318
318
  returned nil, permission was granted on empty password.
319
319
 
320
- * unknown: Thirteenth? public release 1.3.0.beta
320
+ * May 22nd, 2011: Thirteenth public release 1.3.0
321
321
  * Various performance optimizations
322
322
  * Various multipart fixes
323
323
  * Various multipart refactors
@@ -333,8 +333,9 @@ run on port 11211) and memcache-client installed.
333
333
  * Rack::Deflater now supports streaming
334
334
  * Improved Rack::Handler loading and searching
335
335
  * Support for the PATCH verb
336
-
337
-
336
+ * env['rack.session.options'] now contains session options
337
+ * Cookies respect renew
338
+ * Session middleware uses SecureRandom.hex
338
339
 
339
340
  == Contact
340
341
 
@@ -389,7 +390,7 @@ would like to thank:
389
390
  * Marcus Rückert, for help with configuring and debugging lighttpd.
390
391
  * The WSGI team for the well-done and documented work they've done and
391
392
  Rack builds up on.
392
- * All bug reporters and patch contributers not mentioned above.
393
+ * All bug reporters and patch contributors not mentioned above.
393
394
 
394
395
  == Copyright
395
396
 
@@ -415,10 +416,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
415
416
  == Links
416
417
 
417
418
  Rack:: <http://rack.rubyforge.org/>
418
- Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
419
419
  Official Rack repositories:: <http://github.com/rack>
420
- Rack Lighthouse Bug Tracking:: <http://rack.lighthouseapp.com/>
420
+ Rack Bug Tracking:: <http://github.com/rack/rack/issues>
421
421
  rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
422
+ Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
422
423
 
423
424
  Christian Neukirchen:: <http://chneukirchen.org/>
424
425
 
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  # Rakefile for Rack. -*-ruby-*-
2
- require 'rake/rdoctask'
3
2
 
4
3
  desc "Run all the tests"
5
4
  task :default => [:test]
data/SPEC CHANGED
@@ -3,7 +3,7 @@ can (and should) use Rack::Lint to enforce it.
3
3
  When you develop middleware, be sure to add a Lint before and
4
4
  after to catch all mistakes.
5
5
  = Rack applications
6
- A Rack application is an Ruby object (not a class) that
6
+ A Rack application is a Ruby object (not a class) that
7
7
  responds to +call+.
8
8
  It takes exactly one argument, the *environment*
9
9
  and returns an Array of exactly three values:
@@ -106,7 +106,7 @@ The input stream must respond to +gets+, +each+, +read+ and +rewind+.
106
106
  * +gets+ must be called without arguments and return a string,
107
107
  or +nil+ on EOF.
108
108
  * +read+ behaves like IO#read. Its signature is <tt>read([length, [buffer]])</tt>.
109
- If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must
109
+ If given, +length+ must be a non-negative Integer (>= 0) or +nil+, and +buffer+ must
110
110
  be a String and may not be nil. If +length+ is given and not nil, then this method
111
111
  reads at most +length+ bytes from the input stream. If +length+ is not given or nil,
112
112
  then this method reads all data until EOF.
@@ -1,13 +1,13 @@
1
1
  require 'rack/utils'
2
2
 
3
3
  module Rack
4
+
4
5
  # Sets the Content-Length header on responses with fixed-length bodies.
5
6
  class ContentLength
6
7
  include Rack::Utils
7
8
 
8
- def initialize(app, sendfile=nil)
9
+ def initialize(app)
9
10
  @app = app
10
- @sendfile = sendfile
11
11
  end
12
12
 
13
13
  def call(env)
@@ -17,14 +17,13 @@ module Rack
17
17
  if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) &&
18
18
  !headers['Content-Length'] &&
19
19
  !headers['Transfer-Encoding'] &&
20
- !(@sendfile && headers[@sendfile])
21
-
22
- new_body, length = [], 0
23
- body.each do |part|
24
- new_body << part
25
- length += bytesize(part)
26
- end
27
- body = new_body
20
+ body.respond_to?(:to_ary)
21
+
22
+ obody = body
23
+ body, length = [], 0
24
+ obody.each { |part| body << part; length += bytesize(part) }
25
+ obody.close if obody.respond_to?(:close)
26
+
28
27
  headers['Content-Length'] = length.to_s
29
28
  end
30
29
 
@@ -30,7 +30,7 @@ module Rack
30
30
 
31
31
  ## = Rack applications
32
32
 
33
- ## A Rack application is an Ruby object (not a class) that
33
+ ## A Rack application is a Ruby object (not a class) that
34
34
  ## responds to +call+.
35
35
  def call(env=nil)
36
36
  dup._call(env)
@@ -302,7 +302,7 @@ module Rack
302
302
  end
303
303
 
304
304
  ## * +read+ behaves like IO#read. Its signature is <tt>read([length, [buffer]])</tt>.
305
- ## If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must
305
+ ## If given, +length+ must be a non-negative Integer (>= 0) or +nil+, and +buffer+ must
306
306
  ## be a String and may not be nil. If +length+ is given and not nil, then this method
307
307
  ## reads at most +length+ bytes from the input stream. If +length+ is not given or nil,
308
308
  ## then this method reads all data until EOF.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack"
3
- s.version = "1.3.0.beta2"
3
+ s.version = "1.3.0"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "a modular Ruby webserver interface"
6
6
 
@@ -1,21 +1,21 @@
1
- --AaB03x
2
- Content-Disposition: form-data; name="foo"
3
-
4
- bar
5
- --AaB03x
6
- Content-Disposition: form-data; name="files"
7
- Content-Type: multipart/mixed, boundary=BbC04y
8
-
9
- --BbC04y
10
- Content-Disposition: attachment; filename="file.txt"
11
- Content-Type: text/plain
12
-
13
- contents
14
- --BbC04y
15
- Content-Disposition: attachment; filename="flowers.jpg"
16
- Content-Type: image/jpeg
17
- Content-Transfer-Encoding: binary
18
-
19
- contents
20
- --BbC04y--
21
- --AaB03x--
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="foo"
3
+
4
+ bar
5
+ --AaB03x
6
+ Content-Disposition: form-data; name="files"
7
+ Content-Type: multipart/mixed, boundary=BbC04y
8
+
9
+ --BbC04y
10
+ Content-Disposition: attachment; filename="file.txt"
11
+ Content-Type: text/plain
12
+
13
+ contents
14
+ --BbC04y
15
+ Content-Disposition: attachment; filename="flowers.jpg"
16
+ Content-Type: image/jpeg
17
+ Content-Transfer-Encoding: binary
18
+
19
+ contents
20
+ --BbC04y--
21
+ --AaB03x--
@@ -7,13 +7,13 @@ describe Rack::ContentLength do
7
7
  response[1]['Content-Length'].should.equal '13'
8
8
  end
9
9
 
10
- should "set Content-Length even on variable length bodies" do
10
+ should "not set Content-Length on variable length bodies" do
11
11
  body = lambda { "Hello World!" }
12
12
  def body.each ; yield call ; end
13
13
 
14
14
  app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] }
15
15
  response = Rack::ContentLength.new(app).call({})
16
- response[1]['Content-Length'].should.equal '12'
16
+ response[1]['Content-Length'].should.be.nil
17
17
  end
18
18
 
19
19
  should "not change Content-Length if it is already set" do
@@ -28,15 +28,46 @@ describe Rack::ContentLength do
28
28
  response[1]['Content-Length'].should.equal nil
29
29
  end
30
30
 
31
- should "not set Content-Length on sendfile responses" do
32
- app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'X-Sendfile' => 'foo'}, %w(Hello World)] }
33
- response = Rack::ContentLength.new(app, "X-Sendfile").call({})
34
- response[1]['Content-Length'].should.equal nil
35
- end
36
-
37
31
  should "not set Content-Length when Transfer-Encoding is chunked" do
38
32
  app = lambda { |env| [200, {'Transfer-Encoding' => 'chunked'}, []] }
39
33
  response = Rack::ContentLength.new(app).call({})
40
34
  response[1]['Content-Length'].should.equal nil
41
35
  end
36
+
37
+ # Using "Connection: close" for this is fairly contended. It might be useful
38
+ # to have some other way to signal this.
39
+ #
40
+ # should "not force a Content-Length when Connection:close" do
41
+ # app = lambda { |env| [200, {'Connection' => 'close'}, []] }
42
+ # response = Rack::ContentLength.new(app).call({})
43
+ # response[1]['Content-Length'].should.equal nil
44
+ # end
45
+
46
+ should "close bodies that need to be closed" do
47
+ body = Struct.new(:body) do
48
+ attr_reader :closed
49
+ def each; body.join; end
50
+ def close; @closed = true; end
51
+ def to_ary; end
52
+ end.new(%w[one two three])
53
+
54
+ app = lambda { |env| [200, {}, body] }
55
+ response = Rack::ContentLength.new(app).call({})
56
+ body.closed.should.equal true
57
+ end
58
+
59
+ should "support single-execute bodies" do
60
+ body = Struct.new(:body) do
61
+ def each
62
+ yield body.shift until body.empty?
63
+ end
64
+ def to_ary; end
65
+ end.new(%w[one two three])
66
+
67
+ app = lambda { |env| [200, {}, body] }
68
+ response = Rack::ContentLength.new(app).call({})
69
+ expected = %w[one two three]
70
+ response[1]['Content-Length'].should.equal expected.join.size.to_s
71
+ response[2].should.equal expected
72
+ end
42
73
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196407
5
- prerelease: 6
4
+ hash: 27
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
- - beta
11
- - 2
12
- version: 1.3.0.beta2
10
+ version: 1.3.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Christian Neukirchen
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2011-05-19 00:00:00 -04:00
18
+ date: 2011-05-22 00:00:00 -07:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
@@ -294,18 +292,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
294
292
  required_rubygems_version: !ruby/object:Gem::Requirement
295
293
  none: false
296
294
  requirements:
297
- - - ">"
295
+ - - ">="
298
296
  - !ruby/object:Gem::Version
299
- hash: 25
297
+ hash: 3
300
298
  segments:
301
- - 1
302
- - 3
303
- - 1
304
- version: 1.3.1
299
+ - 0
300
+ version: "0"
305
301
  requirements: []
306
302
 
307
303
  rubyforge_project: rack
308
- rubygems_version: 1.6.2
304
+ rubygems_version: 1.5.2
309
305
  signing_key:
310
306
  specification_version: 3
311
307
  summary: a modular Ruby webserver interface