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

Breadcrumb

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

function Request::getProtocolVersion

Returns the protocol version.

If the application is behind a proxy, the protocol version used in the requests between the client and the proxy and between the proxy and the server might be different. This returns the former (from the "Via" header) if the proxy is trusted (see "setTrustedProxies()"), otherwise it returns the latter (from the "SERVER_PROTOCOL" server parameter).

File

vendor/symfony/http-foundation/Request.php, line 1384

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public function getProtocolVersion() : ?string {
    if ($this->isFromTrustedProxy()) {
        preg_match('~^(HTTP/)?([1-9]\\.[0-9]) ~', $this->headers
            ->get('Via') ?? '', $matches);
        if ($matches) {
            return 'HTTP/' . $matches[2];
        }
    }
    return $this->server
        ->get('SERVER_PROTOCOL');
}

API Navigation

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