From fe736a54f914b7cf406988f42df6c5c129d821a5 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 12 Jan 2007 07:01:39 +0000 Subject: Set request.env['REQUEST_URI'] when absent. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5895 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/request.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_controller/request.rb') diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 8c21adb8df..62ce9929da 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -145,19 +145,21 @@ module ActionController @env['RAW_POST_DATA'] end - # Returns the request URI correctly, taking into account the idiosyncracies - # of the various servers. + # Return the request URI, accounting for server idiosyncracies. + # WEBrick includes the full URL. IIS leaves REQUEST_URI blank. def request_uri if uri = @env['REQUEST_URI'] - (%r{^\w+\://[^/]+(/.*|$)$} =~ uri) ? $1 : uri # Remove domain, which webrick puts into the request_uri. - else # REQUEST_URI is blank under IIS - get this from PATH_INFO and SCRIPT_NAME + # Remove domain, which webrick puts into the request_uri. + (%r{^\w+\://[^/]+(/.*|$)$} =~ uri) ? $1 : uri + else + # Construct IIS missing REQUEST_URI from SCRIPT_NAME and PATH_INFO. script_filename = @env['SCRIPT_NAME'].to_s.match(%r{[^/]+$}) uri = @env['PATH_INFO'] uri = uri.sub(/#{script_filename}\//, '') unless script_filename.nil? unless (env_qs = @env['QUERY_STRING']).nil? || env_qs.empty? uri << '?' << env_qs end - uri + @env['REQUEST_URI'] = uri end end -- cgit v1.2.3