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 /railties/lib/rails/rack | |
parent | 71325bb3084c8e5a8542510c32441f34b2811a92 (diff) | |
download | rails-7f184aaf4352140c7e3bd33761058bb05737e11b.tar.gz rails-7f184aaf4352140c7e3bd33761058bb05737e11b.tar.bz2 rails-7f184aaf4352140c7e3bd33761058bb05737e11b.zip |
Use again Rack's ContentLength middleware
Diffstat (limited to 'railties/lib/rails/rack')
-rw-r--r-- | railties/lib/rails/rack/content_length.rb | 38 |
1 files changed, 0 insertions, 38 deletions
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 |