You are here

public function SearchSubscriber::extractHmac in Acquia Search 3.x

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/SearchSubscriber.php \Drupal\acquia_search\EventSubscriber\SearchSubscriber::extractHmac()

Look in the headers and get the hmac_digest out.

Parameters

array $headers: Headers array.

Return value

string Hmac_digest or empty string.

1 call to SearchSubscriber::extractHmac()
SearchSubscriber::authenticateResponse in src/EventSubscriber/SearchSubscriber.php
Validate the hmac for the response body.

File

src/EventSubscriber/SearchSubscriber.php, line 193

Class

SearchSubscriber
Class SearchSubscriber.

Namespace

Drupal\acquia_search\EventSubscriber

Code

public function extractHmac(array $headers) : string {
  $reg = [];
  if (is_array($headers)) {
    foreach ($headers as $value) {
      if (stristr($value, 'pragma') && preg_match("/hmac_digest=([^;]+);/i", $value, $reg)) {
        return trim($reg[1]);
      }
    }
  }
  return '';
}