Skip to content
Browse files

Inherit ActionController::Request from Rack::Request

  • Loading branch information...
1 parent e0fa041 commit e1f73aab8ca679a68a32bec6c0d72eb8a58d8788 @josh josh committed Jan 9, 2009
Showing with 7 additions and 29 deletions.
  1. +6 −28 actionpack/lib/action_controller/request.rb
  2. +1 −1 actionpack/lib/action_controller/request_parser.rb
View
34 actionpack/lib/action_controller/request.rb
@@ -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
@@ -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
@@ -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.
@@ -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
@@ -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
View
2 actionpack/lib/action_controller/request_parser.rb
@@ -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

0 comments on commit e1f73aa

Please sign in to comment.
Something went wrong with that request. Please try again.