class ActionDispatch::Integration::Session

def process(method, path, params: nil, headers: nil, env: nil, xhr: false, as: nil)

Performs the actual request.
def process(method, path, params: nil, headers: nil, env: nil, xhr: false, as: nil)
  request_encoder = RequestEncoder.encoder(as)
  if path =~ %r{://}
    location = URI.parse(path)
    https! URI::HTTPS === location if location.scheme
    if url_host = location.host
      default = Rack::Request::DEFAULT_PORTS[location.scheme]
      url_host += ":#{location.port}" if default != location.port
      host! url_host
    end
    path = request_encoder.append_format_to location.path
    path = location.query ? "#{path}?#{location.query}" : path
  else
    path = request_encoder.append_format_to path
  end
  hostname, port = host.split(':')
  request_env = {
    :method => method,
    :params => request_encoder.encode_params(params),
    "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"   => request_encoder.content_type,
    "HTTP_ACCEPT"    => accept
  }
  if xhr
    headers ||= {}
    headers['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
    headers['HTTP_ACCEPT'] ||= [Mime[:js], Mime[:html], Mime[:xml], 'text/xml', '*/*'].join(', ')
  end
  # this modifies the passed request_env directly
  if headers.present?
    Http::Headers.from_hash(request_env).merge!(headers)
  end
  if env.present?
    Http::Headers.from_hash(request_env).merge!(env)
  end
  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, request_env), request_env)
  @request_count += 1
  @request  = ActionDispatch::Request.new(session.last_request.env)
  response = _mock_session.last_response
  @response = ActionDispatch::TestResponse.from_response(response)
  @response.request = @request
  @response.response_parser = RequestEncoder.parser(@response.content_type)
  @html_document = nil
  @url_options = nil
  @controller = @request.controller_instance
  response.status
end