You are here

protected function VarnishPurgerBase::getHeaders in Varnish purger 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Purge/Purger/VarnishPurgerBase.php \Drupal\varnish_purger\Plugin\Purge\Purger\VarnishPurgerBase::getHeaders()

Retrieve all configured headers that need to be set.

Parameters

array $token_data: An array of keyed objects, to pass on to the token service.

Return value

string[] Associative array with header values and field names in the key.

1 call to VarnishPurgerBase::getHeaders()
VarnishPurgerBase::getOptions in src/Plugin/Purge/Purger/VarnishPurgerBase.php
Retrieve the Guzzle connection options to set.

File

src/Plugin/Purge/Purger/VarnishPurgerBase.php, line 100

Class

VarnishPurgerBase
Abstract base class for HTTP based configurable purgers.

Namespace

Drupal\varnish_purger\Plugin\Purge\Purger

Code

protected function getHeaders($token_data) {
  $headers = [];
  $headers['user-agent'] = 'varnish_purger module for Drupal 8.';
  foreach ($this->settings->headers as $header) {

    // According to https://tools.ietf.org/html/rfc2616#section-4.2, header
    // names are case-insensitive. Therefore, to aid easy overrides by end
    // users, we lower all header names so that no doubles are sent.
    $headers[strtolower($header['field'])] = $this->token
      ->replace($header['value'], $token_data);
  }
  return $headers;
}