diff options
author | James Tucker <jftucker@gmail.com> | 2013-12-28 14:01:48 -0400 |
---|---|---|
committer | James Tucker <jftucker@gmail.com> | 2013-12-28 14:01:48 -0400 |
commit | e068683a3df0dd6c1ee58666ae4a307571abc368 (patch) | |
tree | 59fe73d2293a3897c0f8108217232ca2aa6a6050 /lib/rack/content_length.rb | |
parent | 669deb49dbb571d2f10ddb67fcd8049c5dabf42f (diff) | |
download | rack-e068683a3df0dd6c1ee58666ae4a307571abc368.tar.gz |
Fix race condition in content length
Diffstat (limited to 'lib/rack/content_length.rb')
-rw-r--r-- | lib/rack/content_length.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/rack/content_length.rb b/lib/rack/content_length.rb index 634bdc41..71bc919b 100644 --- a/lib/rack/content_length.rb +++ b/lib/rack/content_length.rb @@ -1,4 +1,5 @@ require 'rack/utils' +require 'rack/body_proxy' module Rack @@ -22,7 +23,10 @@ module Rack obody = body body, length = [], 0 obody.each { |part| body << part; length += bytesize(part) } - obody.close if obody.respond_to?(:close) + + body = BodyProxy.new(body) do + obody.close if obody.respond_to?(:close) + end headers['Content-Length'] = length.to_s end |