public static function Request::create

Creates a Request based on a given URI and configuration.

The information contained in the URI always take precedence over the other information (server and parameters).

@api

Parameters

string $uri The URI:

string $method The HTTP method:

array $parameters The query (GET) or request (POST) parameters:

array $cookies The request cookies ($_COOKIE):

array $files The request files ($_FILES):

array $server The server parameters ($_SERVER):

string $content The raw body data:

Return value

Request A Request instance

134 calls to Request::create()
BinaryFileResponseTest::testRequests in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
@dataProvider provideRanges
BinaryFileResponseTest::testXAccelMapping in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
@dataProvider getSampleXAccelMappings
BinaryFileResponseTest::testXSendfile in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
ChainRouter::doMatch in drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php
Loops through all routers and tries to match the passed request or url.
ChainRouterTest::testMatchRequest in drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/Routing/ChainRouterTest.php
The first usable match is used, no further routers are queried once a match is found

... See full list

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php, line 269

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public static function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null) {
  $server = array_replace(array(
    'SERVER_NAME' => 'localhost',
    'SERVER_PORT' => 80,
    'HTTP_HOST' => 'localhost',
    'HTTP_USER_AGENT' => 'Symfony/2.X',
    'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
    'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
    'REMOTE_ADDR' => '127.0.0.1',
    'SCRIPT_NAME' => '',
    'SCRIPT_FILENAME' => '',
    'SERVER_PROTOCOL' => 'HTTP/1.1',
    'REQUEST_TIME' => time(),
  ), $server);
  $server['PATH_INFO'] = '';
  $server['REQUEST_METHOD'] = strtoupper($method);
  $components = parse_url($uri);
  if (isset($components['host'])) {
    $server['SERVER_NAME'] = $components['host'];
    $server['HTTP_HOST'] = $components['host'];
  }
  if (isset($components['scheme'])) {
    if ('https' === $components['scheme']) {
      $server['HTTPS'] = 'on';
      $server['SERVER_PORT'] = 443;
    }
    else {
      unset($server['HTTPS']);
      $server['SERVER_PORT'] = 80;
    }
  }
  if (isset($components['port'])) {
    $server['SERVER_PORT'] = $components['port'];
    $server['HTTP_HOST'] = $server['HTTP_HOST'] . ':' . $components['port'];
  }
  if (isset($components['user'])) {
    $server['PHP_AUTH_USER'] = $components['user'];
  }
  if (isset($components['pass'])) {
    $server['PHP_AUTH_PW'] = $components['pass'];
  }
  if (!isset($components['path'])) {
    $components['path'] = '/';
  }
  switch (strtoupper($method)) {
    case 'POST':
    case 'PUT':
    case 'DELETE':
      if (!isset($server['CONTENT_TYPE'])) {
        $server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
      }
    case 'PATCH':
      $request = $parameters;
      $query = array();
      break;
    default:
      $request = array();
      $query = $parameters;
      break;
  }
  if (isset($components['query'])) {
    parse_str(html_entity_decode($components['query']), $qs);
    $query = array_replace($qs, $query);
  }
  $queryString = http_build_query($query, '', '&');
  $server['REQUEST_URI'] = $components['path'] . ('' !== $queryString ? '?' . $queryString : '');
  $server['QUERY_STRING'] = $queryString;
  return new static($query, $request, array(), $cookies, $files, $server, $content);
}