You are here

protected function Request::prepareRequestUri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Request.php \Symfony\Component\HttpFoundation\Request::prepareRequestUri()
1 call to Request::prepareRequestUri()
Request::getRequestUri in vendor/symfony/http-foundation/Request.php
Returns the requested URI (path and query string).
1 method overrides Request::prepareRequestUri()
ApacheRequest::prepareRequestUri in vendor/symfony/http-foundation/ApacheRequest.php

File

vendor/symfony/http-foundation/Request.php, line 1675

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

protected function prepareRequestUri() {
  $requestUri = '';
  if ($this->headers
    ->has('X_ORIGINAL_URL')) {

    // IIS with Microsoft Rewrite Module
    $requestUri = $this->headers
      ->get('X_ORIGINAL_URL');
    $this->headers
      ->remove('X_ORIGINAL_URL');
    $this->server
      ->remove('HTTP_X_ORIGINAL_URL');
    $this->server
      ->remove('UNENCODED_URL');
    $this->server
      ->remove('IIS_WasUrlRewritten');
  }
  elseif ($this->headers
    ->has('X_REWRITE_URL')) {

    // IIS with ISAPI_Rewrite
    $requestUri = $this->headers
      ->get('X_REWRITE_URL');
    $this->headers
      ->remove('X_REWRITE_URL');
  }
  elseif ($this->server
    ->get('IIS_WasUrlRewritten') == '1' && $this->server
    ->get('UNENCODED_URL') != '') {

    // IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem)
    $requestUri = $this->server
      ->get('UNENCODED_URL');
    $this->server
      ->remove('UNENCODED_URL');
    $this->server
      ->remove('IIS_WasUrlRewritten');
  }
  elseif ($this->server
    ->has('REQUEST_URI')) {
    $requestUri = $this->server
      ->get('REQUEST_URI');

    // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
    $schemeAndHttpHost = $this
      ->getSchemeAndHttpHost();
    if (strpos($requestUri, $schemeAndHttpHost) === 0) {
      $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
    }
  }
  elseif ($this->server
    ->has('ORIG_PATH_INFO')) {

    // IIS 5.0, PHP as CGI
    $requestUri = $this->server
      ->get('ORIG_PATH_INFO');
    if ('' != $this->server
      ->get('QUERY_STRING')) {
      $requestUri .= '?' . $this->server
        ->get('QUERY_STRING');
    }
    $this->server
      ->remove('ORIG_PATH_INFO');
  }

  // normalize the request URI to ease creating sub-requests from this request
  $this->server
    ->set('REQUEST_URI', $requestUri);
  return $requestUri;
}