Permalink
Browse files

Use again Rack's ContentLength middleware

  • Loading branch information...
spastorino committed Oct 18, 2011
1 parent 71325bb commit 7f184aaf4352140c7e3bd33761058bb05737e11b
Showing with 0 additions and 40 deletions.
  1. +0 −1 railties/lib/rails/commands/server.rb
  2. +0 −1 railties/lib/rails/rack.rb
  3. +0 −38 railties/lib/rails/rack/content_length.rb
@@ -78,7 +78,6 @@ def middleware
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
@@ -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"
@@ -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

1 comment on commit 7f184aa

@spastorino

This comment has been minimized.

Show comment Hide comment
@spastorino

spastorino Oct 18, 2011

Owner

I forgot to replace it with Rack::ContentLength :(, done here d44702c

Owner

spastorino commented on 7f184aa Oct 18, 2011

I forgot to replace it with Rack::ContentLength :(, done here d44702c

Please sign in to comment.