mirror of https://github.com/rails/rails
stop inheriting from Rack::Request
Just include the modules necessary in the Request object to implement the things we need. This should make it easier to build delegate request objects because the API is smaller
This commit is contained in:
parent
3f24fa338f
commit
529136d670
|
@ -29,7 +29,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/rack/rack.git
|
||||
revision: 4080d56bb30f26a2f09053de702896104b5fb64d
|
||||
revision: b2d73960e9ea6b8b15321ef190f13a290d1aedf0
|
||||
branch: master
|
||||
specs:
|
||||
rack (2.0.0.alpha)
|
||||
|
|
|
@ -70,7 +70,7 @@ module ActionController
|
|||
self.content_type = ENCODER.content_type
|
||||
data = ENCODER.build_multipart non_path_parameters
|
||||
else
|
||||
get_header('CONTENT_TYPE') do |k|
|
||||
fetch_header('CONTENT_TYPE') do |k|
|
||||
set_header k, 'application/x-www-form-urlencoded'
|
||||
end
|
||||
|
||||
|
@ -98,7 +98,7 @@ module ActionController
|
|||
set_header 'rack.input', StringIO.new(data)
|
||||
end
|
||||
|
||||
get_header("PATH_INFO") do |k|
|
||||
fetch_header("PATH_INFO") do |k|
|
||||
set_header k, generated_path
|
||||
end
|
||||
path_parameters[:controller] = controller_path
|
||||
|
@ -500,7 +500,7 @@ module ActionController
|
|||
|
||||
if xhr
|
||||
@request.set_header 'HTTP_X_REQUESTED_WITH', 'XMLHttpRequest'
|
||||
@request.get_header('HTTP_ACCEPT') do |k|
|
||||
@request.fetch_header('HTTP_ACCEPT') do |k|
|
||||
@request.set_header k, [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ')
|
||||
end
|
||||
end
|
||||
|
@ -508,7 +508,7 @@ module ActionController
|
|||
@controller.request = @request
|
||||
@controller.response = @response
|
||||
|
||||
@request.get_header("SCRIPT_NAME") do |k|
|
||||
@request.fetch_header("SCRIPT_NAME") do |k|
|
||||
@request.set_header k, @controller.config.relative_url_root
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ module ActionDispatch
|
|||
NULL_PARAM_FILTER = ParameterFilter.new # :nodoc:
|
||||
NULL_ENV_FILTER = ParameterFilter.new ENV_MATCH # :nodoc:
|
||||
|
||||
def initialize(env)
|
||||
def initialize
|
||||
super
|
||||
@filtered_parameters = nil
|
||||
@filtered_env = nil
|
||||
|
@ -48,13 +48,13 @@ module ActionDispatch
|
|||
protected
|
||||
|
||||
def parameter_filter
|
||||
parameter_filter_for get_header("action_dispatch.parameter_filter") {
|
||||
parameter_filter_for fetch_header("action_dispatch.parameter_filter") {
|
||||
return NULL_PARAM_FILTER
|
||||
}
|
||||
end
|
||||
|
||||
def env_filter
|
||||
user_key = get_header("action_dispatch.parameter_filter") {
|
||||
user_key = fetch_header("action_dispatch.parameter_filter") {
|
||||
return NULL_ENV_FILTER
|
||||
}
|
||||
parameter_filter_for(Array(user_key) + ENV_MATCH)
|
||||
|
|
|
@ -64,7 +64,7 @@ module ActionDispatch
|
|||
# If the code block is provided, then it will be run and
|
||||
# its result returned.
|
||||
def fetch(key, default = DEFAULT)
|
||||
@req.get_header(env_name(key)) do
|
||||
@req.fetch_header(env_name(key)) do
|
||||
return default unless default == DEFAULT
|
||||
return yield if block_given?
|
||||
raise NameError, key
|
||||
|
|
|
@ -15,7 +15,7 @@ module ActionDispatch
|
|||
# For backward compatibility, the post \format is extracted from the
|
||||
# X-Post-Data-Format HTTP header if present.
|
||||
def content_mime_type
|
||||
get_header("action_dispatch.request.content_type") do |k|
|
||||
fetch_header("action_dispatch.request.content_type") do |k|
|
||||
v = if get_header('CONTENT_TYPE') =~ /^([^,\;]*)/
|
||||
Mime::Type.lookup($1.strip.downcase)
|
||||
else
|
||||
|
@ -31,7 +31,7 @@ module ActionDispatch
|
|||
|
||||
# Returns the accepted MIME type for the request.
|
||||
def accepts
|
||||
get_header("action_dispatch.request.accepts") do |k|
|
||||
fetch_header("action_dispatch.request.accepts") do |k|
|
||||
header = get_header('HTTP_ACCEPT').to_s.strip
|
||||
|
||||
v = if header.empty?
|
||||
|
@ -54,7 +54,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
def formats
|
||||
get_header("action_dispatch.request.formats") do |k|
|
||||
fetch_header("action_dispatch.request.formats") do |k|
|
||||
params_readable = begin
|
||||
parameters[:format]
|
||||
rescue ActionController::BadRequest
|
||||
|
|
|
@ -13,12 +13,14 @@ require 'action_dispatch/http/url'
|
|||
require 'active_support/core_ext/array/conversions'
|
||||
|
||||
module ActionDispatch
|
||||
class Request < Rack::Request
|
||||
class Request
|
||||
include Rack::Request::Helpers
|
||||
include ActionDispatch::Http::Cache::Request
|
||||
include ActionDispatch::Http::MimeNegotiation
|
||||
include ActionDispatch::Http::Parameters
|
||||
include ActionDispatch::Http::FilterParameters
|
||||
include ActionDispatch::Http::URL
|
||||
include Rack::Request::Env
|
||||
|
||||
autoload :Session, 'action_dispatch/request/session'
|
||||
autoload :Utils, 'action_dispatch/request/utils'
|
||||
|
@ -335,7 +337,7 @@ module ActionDispatch
|
|||
|
||||
# Override Rack's GET method to support indifferent access
|
||||
def GET
|
||||
get_header("action_dispatch.request.query_parameters") do |k|
|
||||
fetch_header("action_dispatch.request.query_parameters") do |k|
|
||||
set_header k, Request::Utils.normalize_encode_params(super || {})
|
||||
end
|
||||
rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e
|
||||
|
@ -345,7 +347,7 @@ module ActionDispatch
|
|||
|
||||
# Override Rack's POST method to support indifferent access
|
||||
def POST
|
||||
get_header("action_dispatch.request.request_parameters") do
|
||||
fetch_header("action_dispatch.request.request_parameters") do
|
||||
self.request_parameters = Request::Utils.normalize_encode_params(super || {})
|
||||
end
|
||||
rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e
|
||||
|
|
|
@ -183,7 +183,7 @@ module ActionDispatch
|
|||
end
|
||||
end
|
||||
|
||||
def initialize(env)
|
||||
def initialize
|
||||
super
|
||||
@protocol = nil
|
||||
@port = nil
|
||||
|
|
|
@ -4,9 +4,9 @@ require 'active_support/message_verifier'
|
|||
require 'active_support/json'
|
||||
|
||||
module ActionDispatch
|
||||
class Request < Rack::Request
|
||||
class Request
|
||||
def cookie_jar
|
||||
get_header('action_dispatch.cookies'.freeze) do
|
||||
fetch_header('action_dispatch.cookies'.freeze) do
|
||||
self.cookie_jar = Cookies::CookieJar.build(self, cookies)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'active_support/core_ext/hash/keys'
|
||||
|
||||
module ActionDispatch
|
||||
class Request < Rack::Request
|
||||
class Request
|
||||
# Access the contents of the flash. Use <tt>flash["notice"]</tt> to
|
||||
# read a notice you put there or <tt>flash["notice"] = "hello"</tt>
|
||||
# to put a new one.
|
||||
|
|
|
@ -95,7 +95,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
def unpacked_cookie_data(req)
|
||||
req.get_header("action_dispatch.request.unsigned_session_cookie") do |k|
|
||||
req.fetch_header("action_dispatch.request.unsigned_session_cookie") do |k|
|
||||
v = stale_session_check! do
|
||||
if data = get_cookie(req)
|
||||
data.stringify_keys!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'rack/session/abstract/id'
|
||||
|
||||
module ActionDispatch
|
||||
class Request < Rack::Request
|
||||
class Request
|
||||
# Session is responsible for lazily loading the session from store.
|
||||
class Session # :nodoc:
|
||||
ENV_SESSION_KEY = Rack::RACK_SESSION # :nodoc:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module ActionDispatch
|
||||
class Request < Rack::Request
|
||||
class Request
|
||||
class Utils # :nodoc:
|
||||
|
||||
mattr_accessor :perform_deep_munge
|
||||
|
|
Loading…
Reference in New Issue