diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-06 16:20:47 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-06 16:20:47 -0700 |
commit | 07b2ff03d04656faccc68c83541b06e318a36ed7 (patch) | |
tree | cea4cb0efdf1d149846958700458ae31e34d7416 /actionpack/lib/action_dispatch/http | |
parent | 6716ad555a687b1e825fa71ba076e641f4dc097a (diff) | |
download | rails-07b2ff03d04656faccc68c83541b06e318a36ed7.tar.gz rails-07b2ff03d04656faccc68c83541b06e318a36ed7.tar.bz2 rails-07b2ff03d04656faccc68c83541b06e318a36ed7.zip |
use a request object to access info from env in GetIp
again, we want to hide the contents of `env` from the implementation.
Allocate a request object to access the contents of env, but save
allocations due to string literal allocations when accessing the env
hash.
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/request.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index c18c2643e4..fb12f77bdb 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -34,7 +34,9 @@ module ActionDispatch HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM - HTTP_NEGOTIATE HTTP_PRAGMA ].freeze + HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP + HTTP_X_FORWARDED_FOR + ].freeze ENV_METHODS.each do |env| class_eval <<-METHOD, __FILE__, __LINE__ + 1 @@ -225,6 +227,10 @@ module ActionDispatch @remote_ip ||= (@env["action_dispatch.remote_ip"] || ip).to_s end + def remote_ip=(remote_ip) + @env["action_dispatch.remote_ip".freeze] = remote_ip + end + ACTION_DISPATCH_REQUEST_ID = "action_dispatch.request_id".freeze # :nodoc: # Returns the unique request id, which is based on either the X-Request-Id header that can |