From e451d47e84f5f15f6bbe63cc079e350ae84287f4 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jan 2016 11:36:32 +1100 Subject: [PATCH] Revert "PERF: send Content-Length from Rails on all requests" This reverts commit ea0e238ae1884e9f2891deafb0d9634a528270cc. Does not seem needed reverting --- config/initializers/300-content_length.rb | 37 ----------------------- 1 file changed, 37 deletions(-) delete mode 100644 config/initializers/300-content_length.rb diff --git a/config/initializers/300-content_length.rb b/config/initializers/300-content_length.rb deleted file mode 100644 index 0938baf6cf3..00000000000 --- a/config/initializers/300-content_length.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Just like Rack except we dont do a to_ary check so we can calculate length -# on body proxy objects -# Sets the Content-Length header on responses with fixed-length bodies. -class ContentLength - TRANSFER_ENCODING = "Transfer-Encoding".freeze - CONTENT_LENGTH = "Content-Length".freeze - - include Rack::Utils - - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - - if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) && - !headers[CONTENT_LENGTH] && - !headers[TRANSFER_ENCODING] - - obody = body - body, length = [], 0 - obody.each { |part| body << part; length += part.bytesize } - - body = Rack::BodyProxy.new(body) do - obody.close if obody.respond_to?(:close) - end - - headers[CONTENT_LENGTH] = length.to_s - end - - [status, headers, body] - end -end - -# content length helps us instruct NGINX on how to deal with this -Rails.configuration.middleware.unshift ContentLength