aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/application.rb3
-rw-r--r--railties/lib/rails/engine.rb12
-rw-r--r--railties/lib/rails/rack.rb8
-rw-r--r--railties/lib/rails/rack/content_length.rb38
-rw-r--r--railties/lib/rails/rack/static.rb5
5 files changed, 54 insertions, 12 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 1e4d25f18c..816bff29b7 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -141,6 +141,8 @@ module Rails
def default_middleware_stack
ActionDispatch::MiddlewareStack.new.tap do |middleware|
+ middleware.use ::Rails::Rack::ContentLength, config.action_dispatch.x_sendfile_header
+
if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache
require "action_dispatch/http/rack_cache"
middleware.use ::Rack::Cache, rack_cache
@@ -195,6 +197,7 @@ module Rails
end
def initialize_console(sandbox=false)
+ require "pp"
require "rails/console/app"
require "rails/console/helpers"
end
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index e26f73ed8d..81a0350724 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -522,9 +522,15 @@ module Rails
end
initializer :append_assets_path do |app|
- app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
- app.config.assets.paths.unshift(*paths["lib/assets"].existent)
- app.config.assets.paths.unshift(*paths["app/assets"].existent)
+ if app.config.assets.respond_to?(:prepend_path)
+ app.config.assets.prepend_path(*paths["vendor/assets"].existent)
+ app.config.assets.prepend_path(*paths["lib/assets"].existent)
+ app.config.assets.prepend_path(*paths["app/assets"].existent)
+ else
+ app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
+ app.config.assets.paths.unshift(*paths["lib/assets"].existent)
+ app.config.assets.paths.unshift(*paths["app/assets"].existent)
+ end
end
initializer :prepend_helpers_path do |app|
diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb
index 1f20ceae44..d4a41b217e 100644
--- a/railties/lib/rails/rack.rb
+++ b/railties/lib/rails/rack.rb
@@ -1,8 +1,8 @@
module Rails
module Rack
- autoload :Debugger, "rails/rack/debugger"
- autoload :Logger, "rails/rack/logger"
- autoload :LogTailer, "rails/rack/log_tailer"
- autoload :Static, "rails/rack/static"
+ autoload :ContentLength, "rails/rack/content_length"
+ autoload :Debugger, "rails/rack/debugger"
+ autoload :Logger, "rails/rack/logger"
+ autoload :LogTailer, "rails/rack/log_tailer"
end
end
diff --git a/railties/lib/rails/rack/content_length.rb b/railties/lib/rails/rack/content_length.rb
new file mode 100644
index 0000000000..6839af4152
--- /dev/null
+++ b/railties/lib/rails/rack/content_length.rb
@@ -0,0 +1,38 @@
+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
diff --git a/railties/lib/rails/rack/static.rb b/railties/lib/rails/rack/static.rb
deleted file mode 100644
index ebe8b9e103..0000000000
--- a/railties/lib/rails/rack/static.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'action_dispatch'
-
-module Rails::Rack
- Static = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Rails::Rack::Static', ActionDispatch::Static)
-end