method
request_uri
v2.1.0 -
Show latest stable
- Class:
ActionController::AbstractRequest
request_uri()public
Return the request URI, accounting for server idiosyncracies. WEBrick includes the full URL. IIS leaves REQUEST_URI blank.
# File actionpack/lib/action_controller/request.rb, line 246
def request_uri
if uri = @env['REQUEST_URI']
# 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
if uri.nil?
@env.delete('REQUEST_URI')
uri
else
@env['REQUEST_URI'] = uri
end
end
end Related methods
- Instance methods
- accepts
- body
- content_length
- content_type
- cookies
- delete?
- domain
- format
- format=
- get?
- head?
- headers
- host
- host_with_port
- method
- parameters
- path
- path_parameters
- path_parameters=
- port
- port_string
- post?
- protocol
- put?
- query_parameters
- query_string
- raw_post
- relative_url_root
- remote_ip
- request_method
- request_parameters
- request_uri
- reset_session
- server_software
- session
- session=
- ssl?
- standard_port
- subdomains
- symbolized_path_parameters
- url
- xhr?
- xml_http_request?
- Protected methods
-
content_type_with_parameters -
content_type_without_parameters - Private methods
-
clean_up_ajax_request_body! -
extract_content_type_without_parameters -
extract_multipart_boundary -
get_typed_value -
parse_multipart_form_parameters -
parse_query_parameters -
parse_request_parameters -
read_multipart -
content_type_from_legacy_post_data_format_header -
named_host? -
parse_formatted_request_parameters