提交 05934d24 编写于 作者: A Aaron Patterson

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.
上级 869b0071
require 'active_support/core_ext/array/extract_options'
require 'action_dispatch/middleware/stack'
require 'active_support/deprecation'
module ActionController
# Extend ActionDispatch middleware stack to make it aware of options
......@@ -119,6 +120,7 @@ class Metal < AbstractController::Base
def env
@_request.env
end
deprecate :env
# Returns the last part of the controller's name, underscored, without the ending
# <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>.
......
......@@ -199,7 +199,7 @@ module Streaming
def _process_options(options) #:nodoc:
super
if options[:stream]
if env["HTTP_VERSION"] == "HTTP/1.0"
if request.version == "HTTP/1.0"
options.delete(:stream)
else
headers["Cache-Control"] ||= "no-cache"
......
......@@ -35,7 +35,7 @@ class Request < Rack::Request
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP
HTTP_X_FORWARDED_FOR
HTTP_X_FORWARDED_FOR HTTP_VERSION
].freeze
ENV_METHODS.each do |env|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册