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

Breadcrumb

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

function Request::setTrustedHosts

Sets a list of trusted host patterns.

You should only list the hosts you manage using regexs.

Parameters

array $hostPatterns A list of trusted host patterns:

2 calls to Request::setTrustedHosts()
DrupalKernel::setupTrustedHosts in core/lib/Drupal/Core/DrupalKernel.php
Sets up the lists of trusted HTTP Host headers.
Kernel::preBoot in vendor/symfony/http-kernel/Kernel.php

File

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

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public static function setTrustedHosts(array $hostPatterns) : void {
    self::$trustedHostPatterns = array_map(fn($hostPattern) => \sprintf('{%s}i', $hostPattern), $hostPatterns);
    // we need to reset trusted hosts on trusted host patterns change
    self::$trustedHosts = [];
}

API Navigation

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