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

deprecate the env method on controller instances

people should be accessing request information through the request
object, not via the env hash.  If they really really want at the env
hash, then they can get it off the request.
This commit is contained in:
Aaron Patterson 2015-08-07 16:27:32 -07:00
parent 869b007172
commit 05934d24af
3 changed files with 4 additions and 2 deletions

View file

@ -1,5 +1,6 @@
require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/array/extract_options'
require 'action_dispatch/middleware/stack' require 'action_dispatch/middleware/stack'
require 'active_support/deprecation'
module ActionController module ActionController
# Extend ActionDispatch middleware stack to make it aware of options # Extend ActionDispatch middleware stack to make it aware of options
@ -119,6 +120,7 @@ module ActionController
def env def env
@_request.env @_request.env
end end
deprecate :env
# Returns the last part of the controller's name, underscored, without the ending # Returns the last part of the controller's name, underscored, without the ending
# <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>. # <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>.

View file

@ -199,7 +199,7 @@ module ActionController #:nodoc:
def _process_options(options) #:nodoc: def _process_options(options) #:nodoc:
super super
if options[:stream] if options[:stream]
if env["HTTP_VERSION"] == "HTTP/1.0" if request.version == "HTTP/1.0"
options.delete(:stream) options.delete(:stream)
else else
headers["Cache-Control"] ||= "no-cache" headers["Cache-Control"] ||= "no-cache"

View file

@ -35,7 +35,7 @@ module ActionDispatch
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
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_X_FORWARDED_FOR HTTP_VERSION
].freeze ].freeze
ENV_METHODS.each do |env| ENV_METHODS.each do |env|