diff options
Diffstat (limited to 'app/middleware/content_length.rb')
-rw-r--r-- | app/middleware/content_length.rb | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/app/middleware/content_length.rb b/app/middleware/content_length.rb deleted file mode 100644 index fa51160..0000000 --- a/app/middleware/content_length.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'rack/utils' - -class ContentLength - - include Rack::Utils - - def initialize app - @app = app - 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'] - - #see https://stackoverflow.com/questions/26534165/unable-to-get-content-length-header-working-under-rails-4-1puma - #see https://github.com/rails/rails/pull/16793 - #&& body.respond_to?(:to_ary) - - obody = body - body, length = [], 0 - obody.each { |part| body << part; length += bytesize(part) } - obody.close if obody.respond_to?(:close) - - headers['Content-Length'] = length.to_s - end - [status, headers, body] - end - -end |