Skip to content

Commit

Permalink
Move content length to the server, this brings the same behavior as i…
Browse files Browse the repository at this point in the history
…n rack 1.2.
  • Loading branch information
josevalim committed May 23, 2011
1 parent c944cab commit 6e5eede
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions railties/lib/rails/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ def config

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
Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/commands/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def middleware
middlewares = []
middlewares << [Rails::Rack::LogTailer, log_path] unless options[:daemonize]
middlewares << [Rails::Rack::Debugger] if options[:debugger]
middlewares << [Rails::Rack::ContentLength]
Hash.new(middlewares)
end

Expand Down
13 changes: 6 additions & 7 deletions railties/test/application/middleware_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def app
boot!

assert_equal [
"Rails::Rack::ContentLength",
"ActionDispatch::Static",
"Rack::Lock",
"ActiveSupport::Cache::Strategy::LocalCache",
Expand Down Expand Up @@ -49,7 +48,7 @@ def app

boot!

assert_equal "Rack::Cache", middleware.second
assert_equal "Rack::Cache", middleware.first
end

test "Rack::SSL is present when force_ssl is set" do
Expand Down Expand Up @@ -104,20 +103,20 @@ def app
end

test "insert middleware after" do
add_to_config "config.middleware.insert_after Rails::Rack::ContentLength, Rack::Config"
add_to_config "config.middleware.insert_after ActionDispatch::Static, Rack::Config"
boot!
assert_equal "Rack::Config", middleware.second
end

test "RAILS_CACHE does not respond to middleware" do
add_to_config "config.cache_store = :memory_store"
boot!
assert_equal "Rack::Runtime", middleware.fourth
assert_equal "Rack::Runtime", middleware.third
end

test "RAILS_CACHE does respond to middleware" do
boot!
assert_equal "Rack::Runtime", middleware.fifth
assert_equal "Rack::Runtime", middleware.fourth
end

test "identity map is inserted" do
Expand All @@ -127,7 +126,7 @@ def app
end

test "insert middleware before" do
add_to_config "config.middleware.insert_before Rails::Rack::ContentLength, Rack::Config"
add_to_config "config.middleware.insert_before ActionDispatch::Static, Rack::Config"
boot!
assert_equal "Rack::Config", middleware.first
end
Expand Down Expand Up @@ -201,4 +200,4 @@ def middleware
AppTemplate::Application.middleware.map(&:klass).map(&:name)
end
end
end
end

0 comments on commit 6e5eede

Please sign in to comment.