Transfer-Encoding: chunked
ヘッダーの代わりにContent-Length: 42
ヘッダーで応答したいと思います。Content-Lengthヘッダーに応答します
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 < 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 << 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
我々が見ることができるように、Rack::ContentLength
が存在している:私はここにRailsの5.0.0.beta3上だと
は私のapplication.rbです。アクションで は、私もしてヘッダーを設定します。
response.headers['Content-Length'] = body.length
しかし、HTTP応答のいずれかのContent-Length
ヘッダーがありませんがあります:
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:</>; class="home"; rel="self"
Transfer-Encoding:chunked
Vary:Accept-Encoding
はところで、私はそれを削除する方法については考えているTransfer-Encoding
不要なヘッダー。
ベストプラクティスまたはヒントをお持ちの場合は、歓迎してください。ありがとう。