method
process
v4.2.1 -
Show latest stable
- Class:
ActionDispatch::Integration::Session
process(method, path, parameters = nil, headers_or_env = nil)private
Performs the actual request.
# File actionpack/lib/action_dispatch/testing/integration.rb, line 265
def process(method, path, parameters = nil, headers_or_env = nil)
if path =~ %{://}
location = URI.parse(path)
https! URI::HTTPS === location if location.scheme
host! "#{location.host}:#{location.port}" if location.host
path = location.query ? "#{location.path}?#{location.query}" : location.path
end
hostname, port = host.split(':')
env = {
:method => method,
:params => parameters,
"SERVER_NAME" => hostname,
"SERVER_PORT" => port || (https? ? "443" : "80"),
"HTTPS" => https? ? "on" : "off",
"rack.url_scheme" => https? ? "https" : "http",
"REQUEST_URI" => path,
"HTTP_HOST" => host,
"REMOTE_ADDR" => remote_addr,
"CONTENT_TYPE" => "application/x-www-form-urlencoded",
"HTTP_ACCEPT" => accept
}
# this modifies the passed env directly
Http::Headers.new(env).merge!(headers_or_env || {})
session = Rack::Test::Session.new(_mock_session)
# NOTE: rack-test v0.5 doesn't build a default uri correctly
# Make sure requested path is always a full uri
session.request(build_full_uri(path, env), env)
@request_count += 1
@request = ActionDispatch::Request.new(session.last_request.env)
response = _mock_session.last_response
@response = ActionDispatch::TestResponse.new(response.status, response.headers, response.body)
@html_document = nil
@url_options = nil
@controller = session.last_request.env['action_controller.instance']
return response.status
end Related methods
- Instance methods
- cookies
- host
- https!
- https?
- reset!
- url_options
- Class methods
- new
- Private methods
-
_mock_session -
build_full_uri -
process