Skip to content

Commit

Permalink
Do not eagerly load Request before initializers
Browse files Browse the repository at this point in the history
Without those changes the configurations to ActionDispatch::Request
could not be applied in initializers.
  • Loading branch information
rafaelfranca committed Jan 27, 2021
1 parent b623ee9 commit 13a96dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion actionpack/lib/action_dispatch/middleware/cookies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require "rack/utils"

module ActionDispatch
class Request
module RequestCookieMethods
def cookie_jar
fetch_header("action_dispatch.cookies") do
self.cookie_jar = Cookies::CookieJar.build(self, cookies)
Expand Down Expand Up @@ -88,6 +88,10 @@ def use_cookies_with_metadata
# :startdoc:
end

ActiveSupport.on_load(:action_dispatch_request) do
include RequestCookieMethods
end

# Read and write data to cookies through ActionController#cookies.
#
# When reading cookie data, the data is read from the HTTP request header, Cookie.
Expand Down
7 changes: 5 additions & 2 deletions actionpack/lib/action_dispatch/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ class Railtie < Rails::Railtie # :nodoc:
initializer "action_dispatch.configure" do |app|
ActionDispatch::Http::URL.secure_protocol = app.config.force_ssl
ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
ActionDispatch::Request::Utils.perform_deep_munge = app.config.action_dispatch.perform_deep_munge

ActiveSupport.on_load(:action_dispatch_request) do
self.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
ActionDispatch::Request::Utils.perform_deep_munge = app.config.action_dispatch.perform_deep_munge
end

ActiveSupport.on_load(:action_dispatch_response) do
self.default_charset = app.config.action_dispatch.default_charset || app.config.encoding
Expand Down
1 change: 0 additions & 1 deletion actionpack/lib/action_dispatch/routing/route_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require "active_support/core_ext/module/remove_method"
require "active_support/core_ext/array/extract_options"
require "action_controller/metal/exceptions"
require "action_dispatch/http/request"
require "action_dispatch/routing/endpoint"

module ActionDispatch
Expand Down

0 comments on commit 13a96dd

Please sign in to comment.