Skip to content

Commit

Permalink
Inherit ActionController::Request from Rack::Request
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 9, 2009
1 parent e0fa041 commit e1f73aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
34 changes: 6 additions & 28 deletions actionpack/lib/action_controller/request.rb
Expand Up @@ -6,25 +6,17 @@
require 'action_controller/cgi_ext'

module ActionController
# CgiRequest and TestRequest provide concrete implementations.
class Request
class Request < Rack::Request
extend ActiveSupport::Memoizable

class SessionFixationAttempt < StandardError #:nodoc:
end

# The hash of environment variables for this request,
# such as { 'RAILS_ENV' => 'production' }.
attr_reader :env

def initialize(env)
@env = env
super
@parser = ActionController::RequestParser.new(env)
end

%w[ AUTH_TYPE GATEWAY_INTERFACE PATH_INFO
%w[ AUTH_TYPE GATEWAY_INTERFACE
PATH_TRANSLATED REMOTE_HOST
REMOTE_IDENT REMOTE_USER SCRIPT_NAME
REMOTE_IDENT REMOTE_USER REMOTE_ADDR
SERVER_NAME SERVER_PROTOCOL

HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
Expand All @@ -45,8 +37,7 @@ def key?(key)
# The true HTTP request \method as a lowercase symbol, such as <tt>:get</tt>.
# UnknownHttpMethod is raised for invalid methods not listed in ACCEPTED_HTTP_METHODS.
def request_method
method = @env['REQUEST_METHOD']
HTTP_METHOD_LOOKUP[method] || raise(UnknownHttpMethod, "#{method}, accepted HTTP methods are #{HTTP_METHODS.to_sentence}")
HTTP_METHOD_LOOKUP[super] || raise(UnknownHttpMethod, "#{super}, accepted HTTP methods are #{HTTP_METHODS.to_sentence}")
end
memoize :request_method

Expand Down Expand Up @@ -93,7 +84,7 @@ def headers

# Returns the content length of the request as an integer.
def content_length
@env["action_controller.request.content_length"] ||= @env['CONTENT_LENGTH'].to_i
super.to_i
end

# The MIME type of the HTTP request, such as Mime::XML.
Expand Down Expand Up @@ -421,15 +412,6 @@ def body
@parser.body
end

def remote_addr
@env['REMOTE_ADDR']
end

def referrer
@env['HTTP_REFERER']
end
alias referer referrer

def query_parameters
@parser.query_parameters
end
Expand All @@ -442,10 +424,6 @@ def body_stream #:nodoc:
@env['rack.input']
end

def cookies
Rack::Request.new(@env).cookies
end

def session
@env['rack.session'] ||= {}
end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/request_parser.rb
Expand Up @@ -91,7 +91,7 @@ def parse_formatted_request_parameters
end

def content_length
@env["action_controller.request.content_length"] ||= @env['CONTENT_LENGTH'].to_i
@env['CONTENT_LENGTH'].to_i
end

# The raw content type string. Use when you need parameters such as
Expand Down

0 comments on commit e1f73aa

Please sign in to comment.