diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-10-18 16:03:58 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-10-18 16:04:15 -0200 |
commit | 7f184aaf4352140c7e3bd33761058bb05737e11b (patch) | |
tree | 065ecaddffdc5dbc0c05d54ede5c5e23f6e28fcb | |
parent | 71325bb3084c8e5a8542510c32441f34b2811a92 (diff) | |
download | rails-7f184aaf4352140c7e3bd33761058bb05737e11b.tar.gz rails-7f184aaf4352140c7e3bd33761058bb05737e11b.tar.bz2 rails-7f184aaf4352140c7e3bd33761058bb05737e11b.zip |
Use again Rack's ContentLength middleware
-rw-r--r-- | railties/lib/rails/commands/server.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/rack.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/rack/content_length.rb | 38 |
3 files changed, 0 insertions, 40 deletions
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 23392276d5..71e3711ba1 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -78,7 +78,6 @@ module Rails middlewares = [] middlewares << [Rails::Rack::LogTailer, log_path] unless options[:daemonize] middlewares << [Rails::Rack::Debugger] if options[:debugger] - middlewares << [Rails::Rack::ContentLength] Hash.new(middlewares) end diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb index d4a41b217e..d1ee96f7fd 100644 --- a/railties/lib/rails/rack.rb +++ b/railties/lib/rails/rack.rb @@ -1,6 +1,5 @@ module Rails module Rack - autoload :ContentLength, "rails/rack/content_length" autoload :Debugger, "rails/rack/debugger" autoload :Logger, "rails/rack/logger" autoload :LogTailer, "rails/rack/log_tailer" diff --git a/railties/lib/rails/rack/content_length.rb b/railties/lib/rails/rack/content_length.rb deleted file mode 100644 index 6839af4152..0000000000 --- a/railties/lib/rails/rack/content_length.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'action_dispatch' -require 'rack/utils' - -module Rails - module Rack - # Sets the Content-Length header on responses with fixed-length bodies. - class ContentLength - include ::Rack::Utils - - def initialize(app, sendfile=nil) - @app = app - @sendfile = sendfile - end - - def call(env) - status, headers, body = @app.call(env) - headers = HeaderHash.new(headers) - - if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) && - !headers['Content-Length'] && - !headers['Transfer-Encoding'] && - !(@sendfile && headers[@sendfile]) - - old_body = body - body, length = [], 0 - old_body.each do |part| - body << part - length += bytesize(part) - end - old_body.close if old_body.respond_to?(:close) - headers['Content-Length'] = length.to_s - end - - [status, headers, body] - end - end - end -end
\ No newline at end of file |