You are here

function _parse_request_uri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/functions.php \GuzzleHttp\Psr7\_parse_request_uri()

Constructs a URI for an HTTP request message.

@internal

Parameters

string $path Path from the start-line:

array $headers Array of headers (each value an array).:

Return value

string

1 call to _parse_request_uri()
parse_request in vendor/guzzlehttp/psr7/src/functions.php
Parses a request message string into a request object.

File

vendor/guzzlehttp/psr7/src/functions.php, line 769

Namespace

GuzzleHttp\Psr7

Code

function _parse_request_uri($path, array $headers) {
  $hostKey = array_filter(array_keys($headers), function ($k) {
    return strtolower($k) === 'host';
  });

  // If no host is found, then a full URI cannot be constructed.
  if (!$hostKey) {
    return $path;
  }
  $host = $headers[reset($hostKey)][0];
  $scheme = substr($host, -4) === ':443' ? 'https' : 'http';
  return $scheme . '://' . $host . '/' . ltrim($path, '/');
}