Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Message.php

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

Message

Namespace

GuzzleHttp\Psr7

Code

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, '/');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal