You are here

protected function HttpPurgerBase::getHeaders in Generic HTTP Purger 8

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 HttpPurgerBase::getHeaders()
HttpPurgerBase::getOptions in src/Plugin/Purge/Purger/HttpPurgerBase.php
Retrieve the Guzzle connection options to set.

File

src/Plugin/Purge/Purger/HttpPurgerBase.php, line 102

Class

HttpPurgerBase
Abstract base class for HTTP based configurable purgers.

Namespace

Drupal\purge_purger_http\Plugin\Purge\Purger

Code

protected function getHeaders(array $token_data) {
  $headers = [];
  $headers['user-agent'] = 'purge_purger_http module for Drupal 8.';
  if (strlen($this->settings->body)) {
    $headers['content-type'] = $this->settings->body_content_type;
  }
  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;
}