title: Responds with a Content-Length header
body: <p>I would like to respond with a <code>Content-Length: 42</code> header instead of <code>Transfer-Encoding: chunked</code> header.</p>
  
  <p>I'm on Rails 5.0.0.beta3 and here is my application.rb:</p>
  
  <pre><code>require File.expand_path('../boot', __FILE__)
  
  require "rails"
  # Pick the frameworks you want:
  require "active_model/railtie"
  require "active_job/railtie"
  require "active_record/railtie"
  require "action_controller/railtie"
  require "action_mailer/railtie"
  require "action_view/railtie"
  require "action_cable/engine"
  require "sprockets/railtie"
  # require "rails/test_unit/railtie"
  
  # Require the gems listed in Gemfile, including any gems
  # you've limited to :test, :development, or :production.
  Bundler.require(*Rails.groups)
  
  module FuuBarApp
    class Application &lt; Rails::Application
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.
  
      config.active_record.schema_format = :sql
      # config.api_only = true
      config.autoload_paths &lt;&lt; Rails.root.join('lib')
  
      # content compression
      config.middleware.use(Rack::Deflater)
  
      # looks like for view partial caching
      config.middleware.delete(ActionView::Digestor::PerRequestDigestCacheExpiry)
  
      # remove session related middleware
      config.middleware.delete(ActionDispatch::Cookies)
      config.middleware.delete(ActionDispatch::Session::CookieStore)
      config.middleware.delete(ActionDispatch::Flash)
  
      # remove browser related middleware
      # config.middleware.delete(ActionDispatch::BestStandardsSupport)
      config.middleware.delete(Rack::MethodOverride)
  
      # used to serve static assets
      config.middleware.delete(ActionDispatch::Static)
  
      # sets env["rack.multithread"] flag to true and wraps the application within a Mutex
      config.middleware.delete(Rack::Lock)
  
      # used for memory caching. This cache is not thread safe
      # config.middleware.delete(ActiveSupport::Cache::Strategy::LocalCache::Middleware)
  
      # sets an X-Runtime header, containing the time (in seconds) taken to execute the request
      config.middleware.delete(Rack::Runtime)
  
      # makes a unique X-Request-Id header available to the response and enables the ActionDispatch::Request#uuid method
      config.middleware.delete(ActionDispatch::RequestId)
  
      # notifies the logs that the request has began
      # after request is complete, flushes all the logs
      config.middleware.delete(Rails::Rack::Logger)
  
      # rescues any exception returned by the application and calls an exceptions app that will wrap it in a format for the end user
      config.middleware.delete(ActionDispatch::ShowExceptions)
  
      # responsible for logging exceptions and showing a debugging page in case the request is local
      config.middleware.delete(ActionDispatch::DebugExceptions)
  
      # checks for IP spoofing attacks
      config.middleware.delete(ActionDispatch::RemoteIp)
  
      # runs the prepare callbacks before serving the request
      config.middleware.delete(ActionDispatch::Callbacks)
  
      # cleans active connections after each request, unless the rack.test key in the request environment is set to true
      config.middleware.delete(ActiveRecord::ConnectionAdapters::ConnectionManagement)
  
      # adds support for "Conditional GET" so that server responds with nothing if page wasn't changed
      config.middleware.delete(Rack::ConditionalGet)
  
      # adds ETag header on all String bodies
      # ETags are used to validate cache
      config.middleware.delete(Rack::ETag)
  
      config.middleware.use(Rack::ContentLength)
  
      config.action_dispatch.default_headers = {}
    end
  end
  </code></pre>
  
  <p>As we can see, the <code>Rack::ContentLength</code> is present.
  In the actions, I also sets the header with:</p>
  
  <pre><code>response.headers['Content-Length'] = body.length
  </code></pre>
  
  <p>But there's however no any <code>Content-Length</code> header in the HTTP responses:</p>
  
  <pre><code>Allow:GET, HEAD, OPTIONS
  Cache-Control:max-age=31557600, public
  Content-Encoding:gzip
  Content-Language:en
  Content-Type:application/json; charset=utf-8
  ETag:3bfc269594ef649228e9a74bab00f042efc91d5acc6fbee31a382e80d42388fe
  Last-Modified:Tue, 03 May 2016 19:59:21 GMT
  Link:&lt;/&gt;; class="home"; rel="self"
  Transfer-Encoding:chunked
  Vary:Accept-Encoding
  </code></pre>
  
  <p>BTW, I have no idea about how to remove that <code>Transfer-Encoding</code> unwanted header.</p>
  
  <p>If you have a best practice, or a tip, please welcome. Thanks.</p>