function Message::parseRequestUri
Constructs a URI for an HTTP request message.
Parameters
string $path Path from the start-line:
array $headers Array of headers (each value an array).:
1 call to Message::parseRequestUri()
- Message::parseRequest in vendor/
guzzlehttp/ psr7/ src/ Message.php - Parses a request message string into a request object.
File
-
vendor/
guzzlehttp/ psr7/ src/ Message.php, line 176
Class
Namespace
GuzzleHttp\Psr7Code
public static function parseRequestUri(string $path, array $headers) : string {
$hostKey = array_filter(array_keys($headers), function ($k) {
// Numeric array keys are converted to int by PHP.
$k = (string) $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, '/');
}