You are here

public static function ServerRequestFactory::marshalHostAndPortFromHeaders in Zircon Profile 8

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

Marshal the host and port from HTTP headers and/or the PHP environment

Parameters

stdClass $accumulator:

array $server:

array $headers:

1 call to ServerRequestFactory::marshalHostAndPortFromHeaders()
ServerRequestFactory::marshalUriFromServer in vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php
Marshal the URI from the $_SERVER array and headers

File

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

Class

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

Namespace

Zend\Diactoros

Code

public static function marshalHostAndPortFromHeaders(stdClass $accumulator, array $server, array $headers) {
  if (self::getHeader('host', $headers, false)) {
    self::marshalHostAndPortFromHeader($accumulator, self::getHeader('host', $headers));
    return;
  }
  if (!isset($server['SERVER_NAME'])) {
    return;
  }
  $accumulator->host = $server['SERVER_NAME'];
  if (isset($server['SERVER_PORT'])) {
    $accumulator->port = (int) $server['SERVER_PORT'];
  }
  if (!isset($server['SERVER_ADDR']) || !preg_match('/^\\[[0-9a-fA-F\\:]+\\]$/', $accumulator->host)) {
    return;
  }

  // Misinterpreted IPv6-Address
  // Reported for Safari on Windows
  self::marshalIpv6HostAndPort($accumulator, $server);
}