diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-03-13 17:13:10 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-03-13 17:13:10 -0500 |
commit | eced3d8c55c1bbae6915d7c6523c341bc682509a (patch) | |
tree | 055a7c570efed873649188bbdaf7a032f3587806 /actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb | |
parent | 99d75a7b02bf430a124b9c3e2515850959d78acf (diff) | |
download | rails-eced3d8c55c1bbae6915d7c6523c341bc682509a.tar.gz rails-eced3d8c55c1bbae6915d7c6523c341bc682509a.tar.bz2 rails-eced3d8c55c1bbae6915d7c6523c341bc682509a.zip |
Update rack to fix multipart uploads with an empty file [#1945 state:resolved]
Diffstat (limited to 'actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb')
-rw-r--r-- | actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb | 54 |
1 files changed, 19 insertions, 35 deletions
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb index ec4dac96f8..44a33ce36e 100644 --- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb +++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb @@ -374,59 +374,43 @@ module Rack ## === The Content-Length def check_content_length(status, headers, env) - chunked_response = false - headers.each { |key, value| - if key.downcase == 'transfer-encoding' - chunked_response = value.downcase != 'identity' - end - } - headers.each { |key, value| if key.downcase == 'content-length' - ## There must be a <tt>Content-Length</tt>, except when the - ## +Status+ is 1xx, 204 or 304, in which case there must be none - ## given. + ## There must not be a <tt>Content-Length</tt> header when the + ## +Status+ is 1xx, 204 or 304. assert("Content-Length header found in #{status} response, not allowed") { not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i } - assert('Content-Length header should not be used if body is chunked') { - not chunked_response - } - bytes = 0 string_body = true - @body.each { |part| - unless part.kind_of?(String) - string_body = false - break - end + if @body.respond_to?(:to_ary) + @body.each { |part| + unless part.kind_of?(String) + string_body = false + break + end - bytes += Rack::Utils.bytesize(part) - } - - if env["REQUEST_METHOD"] == "HEAD" - assert("Response body was given for HEAD request, but should be empty") { - bytes == 0 + bytes += Rack::Utils.bytesize(part) } - else - if string_body - assert("Content-Length header was #{value}, but should be #{bytes}") { - value == bytes.to_s + + if env["REQUEST_METHOD"] == "HEAD" + assert("Response body was given for HEAD request, but should be empty") { + bytes == 0 } + else + if string_body + assert("Content-Length header was #{value}, but should be #{bytes}") { + value == bytes.to_s + } + end end end return end } - - if [ String, Array ].include?(@body.class) && !chunked_response - assert('No Content-Length header found') { - Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i - } - end end ## === The Body |