You are here

public function SearchApiAcquiaSearchHttpTransport::prepareRequest in Acquia Search for Search API 7

Modify the url and add headers appropriate to authenticate to Acquia Search.

Return value

The nonce used in the request.

1 call to SearchApiAcquiaSearchHttpTransport::prepareRequest()
SearchApiAcquiaSearchHttpTransport::performHttpRequest in includes/SearchApiAcquiaSearchHttpTransport.php
Overrides SearchApiSolrHttpTransport::performHttpRequest().

File

includes/SearchApiAcquiaSearchHttpTransport.php, line 130
Contains SearchApiAcquiaSearchHttpTransport.

Class

SearchApiAcquiaSearchHttpTransport
HTTP transport for connections to the Acquia Search Service.

Code

public function prepareRequest(&$url, &$options, $use_data = TRUE) {
  $id = uniqid();
  if (!stristr($url, '?')) {
    $url .= "?";
  }
  else {
    $url .= "&";
  }
  $url .= 'request_id=' . $id;
  if ($use_data && isset($options['data'])) {
    list($cookie, $nonce) = $this
      ->authCookie($url, $options['data']);
  }
  else {
    list($cookie, $nonce) = $this
      ->authCookie($url);
  }
  if (empty($cookie)) {
    throw new Exception('Invalid authentication string - subscription keys expired or missing.');
  }
  $options['headers']['Cookie'] = $cookie;
  $options['headers'] += array(
    'User-Agent' => 'search_api_acquia/' . variable_get('search_api_acquia_version', '7.x'),
  );
  $options['context'] = acquia_agent_stream_context_create($url, 'acquia_search');
  if (!$options['context']) {
    throw new Exception(t("Could not create stream context"));
  }
  return $nonce;
}