From 2277fbedbea930fb8ce38ab7eb133de6fcc4a2d6 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 7 Feb 2009 00:08:28 -0600 Subject: Temporarily bundle Rack 1.0 prerelease for testing --- .../vendor/rack-1.0/rack/content_length.rb | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb (limited to 'actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb') diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb new file mode 100644 index 0000000000..bce22a32c5 --- /dev/null +++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb @@ -0,0 +1,27 @@ +require 'rack/utils' + +module Rack + # Sets the Content-Length header on responses with fixed-length bodies. + class ContentLength + def initialize(app) + @app = app + end + + def call(env) + status, headers, body = @app.call(env) + headers = Utils::HeaderHash.new(headers) + + if !Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) && + !headers['Content-Length'] && + !headers['Transfer-Encoding'] && + (body.respond_to?(:to_ary) || body.respond_to?(:to_str)) + + body = [body] if body.respond_to?(:to_str) # rack 0.4 compat + length = body.to_ary.inject(0) { |len, part| len + part.length } + headers['Content-Length'] = length.to_s + end + + [status, headers, body] + end + end +end -- cgit v1.2.3 From f2c7508befb085ffe19ec7fb9ca2e6919cc919c9 Mon Sep 17 00:00:00 2001 From: Russ Smith Date: Wed, 11 Mar 2009 12:50:24 -0500 Subject: Update bundled Rack to fix Litespeed compatibility [#2198 state:resolved] Signed-off-by: Joshua Peek --- .../lib/action_controller/vendor/rack-1.0/rack/content_length.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb') diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb index bce22a32c5..1e56d43853 100644 --- a/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb @@ -3,21 +3,23 @@ require 'rack/utils' module Rack # Sets the Content-Length header on responses with fixed-length bodies. class ContentLength + include Rack::Utils + def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) + headers = HeaderHash.new(headers) - if !Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) && + if !STATUS_WITH_NO_ENTITY_BODY.include?(status) && !headers['Content-Length'] && !headers['Transfer-Encoding'] && (body.respond_to?(:to_ary) || body.respond_to?(:to_str)) body = [body] if body.respond_to?(:to_str) # rack 0.4 compat - length = body.to_ary.inject(0) { |len, part| len + part.length } + length = body.to_ary.inject(0) { |len, part| len + bytesize(part) } headers['Content-Length'] = length.to_s end -- cgit v1.2.3