You are here

public static function ServerRequestFactory::normalizeServer in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php \Zend\Diactoros\ServerRequestFactory::normalizeServer()

Marshal the $_SERVER array

Pre-processes and returns the $_SERVER superglobal.

Parameters

array $server:

Return value

array

2 calls to ServerRequestFactory::normalizeServer()
DiactorosFactory::createRequest in vendor/symfony/psr-http-message-bridge/Factory/DiactorosFactory.php
Creates a PSR-7 Request instance from a Symfony one.
ServerRequestFactory::fromGlobals in vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php
Create a request from the supplied superglobal values.

File

vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php, line 131

Class

ServerRequestFactory
Class for marshaling a request object from the current PHP environment.

Namespace

Zend\Diactoros

Code

public static function normalizeServer(array $server) {

  // This seems to be the only way to get the Authorization header on Apache
  $apacheRequestHeaders = self::$apacheRequestHeaders;
  if (isset($server['HTTP_AUTHORIZATION']) || !is_callable($apacheRequestHeaders)) {
    return $server;
  }
  $apacheRequestHeaders = $apacheRequestHeaders();
  if (isset($apacheRequestHeaders['Authorization'])) {
    $server['HTTP_AUTHORIZATION'] = $apacheRequestHeaders['Authorization'];
    return $server;
  }
  if (isset($apacheRequestHeaders['authorization'])) {
    $server['HTTP_AUTHORIZATION'] = $apacheRequestHeaders['authorization'];
    return $server;
  }
  return $server;
}