[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/laminas/laminas-diactoros/src/functions/ -> marshal_protocol_version_from_sapi.php (source)

   1  <?php
   2  
   3  /**
   4   * @see       https://github.com/laminas/laminas-diactoros for the canonical source repository
   5   * @copyright https://github.com/laminas/laminas-diactoros/blob/master/COPYRIGHT.md
   6   * @license   https://github.com/laminas/laminas-diactoros/blob/master/LICENSE.md New BSD License
   7   */
   8  
   9  declare(strict_types=1);
  10  
  11  namespace Laminas\Diactoros;
  12  
  13  use function preg_match;
  14  
  15  /**
  16   * Return HTTP protocol version (X.Y) as discovered within a `$_SERVER` array.
  17   *
  18   * @throws Exception\UnrecognizedProtocolVersionException if the
  19   *     $server['SERVER_PROTOCOL'] value is malformed.
  20   */
  21  function marshalProtocolVersionFromSapi(array $server) : string
  22  {
  23      if (! isset($server['SERVER_PROTOCOL'])) {
  24          return '1.1';
  25      }
  26  
  27      if (! preg_match('#^(HTTP/)?(?P<version>[1-9]\d*(?:\.\d)?)$#', $server['SERVER_PROTOCOL'], $matches)) {
  28          throw Exception\UnrecognizedProtocolVersionException::forVersion(
  29              (string) $server['SERVER_PROTOCOL']
  30          );
  31      }
  32  
  33      return $matches['version'];
  34  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer