public function SearchSubscriber::preExecuteRequest in Acquia Search Multiple Indexes 8
Build Acquia Solr Search Authenticator.
Parameters
PreExecuteRequestEvent $event:
File
- src/
EventSubscriber/ SearchSubscriber.php, line 37
Class
Namespace
Drupal\acquia_search_multi_subs\EventSubscriberCode
public function preExecuteRequest($event) {
$request = $event
->getRequest();
$request
->addParam('request_id', uniqid(), TRUE);
$endpoint = $this->client
->getEndpoint();
$this->uri = $endpoint
->getBaseUri() . $request
->getUri();
$this->nonce = Crypt::randomBytesBase64(24);
$string = $request
->getRawData();
if (!$string) {
$parsed_url = parse_url($this->uri);
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '/';
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
// For pings only.
$string = $path . $query;
}
$cookie = $this
->calculateAuthCookie($string, $this->nonce, NULL, $this->client
->getEndpoint()
->getOption('core'));
$request
->addHeader('Cookie: ' . $cookie);
$request
->addHeader('User-Agent: ' . 'acquia_search/' . \Drupal::config('acquia_search.settings')
->get('version'));
}