Skip to content

Commit

Permalink
deprecate the env method on controller instances
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tenderlove committed Aug 7, 2015
1 parent 869b007 commit 05934d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions actionpack/lib/action_controller/metal.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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
Expand Down Expand Up @@ -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>.
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/streaming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 05934d2

Please sign in to comment.