1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove more direct access to env

This commit is contained in:
Aaron Patterson 2015-08-24 16:14:42 -07:00
parent a1ff5585bd
commit cccc759ff7
2 changed files with 4 additions and 3 deletions

View file

@ -35,7 +35,8 @@ module ActionDispatch
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP
HTTP_X_FORWARDED_FOR HTTP_VERSION HTTP_X_FORWARDED_FOR HTTP_VERSION
HTTP_X_REQUEST_ID HTTP_X_REQUEST_ID HTTP_X_FORWARDED_HOST
SERVER_ADDR
].freeze ].freeze
ENV_METHODS.each do |env| ENV_METHODS.each do |env|

View file

@ -229,10 +229,10 @@ module ActionDispatch
# req = Request.new 'HTTP_HOST' => 'example.com:8080' # req = Request.new 'HTTP_HOST' => 'example.com:8080'
# req.raw_host_with_port # => "example.com:8080" # req.raw_host_with_port # => "example.com:8080"
def raw_host_with_port def raw_host_with_port
if forwarded = env["HTTP_X_FORWARDED_HOST"].presence if forwarded = x_forwarded_host.presence
forwarded.split(/,\s?/).last forwarded.split(/,\s?/).last
else else
env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}" get_header('HTTP_HOST') || "#{server_name || server_addr}:#{get_header('SERVER_PORT')}"
end end
end end