public function SearchApiAcquiaSearchConnection::prepareRequest in Acquia Search for Search API 7.2
Modify the url and add headers appropriate to authenticate to Acquia Search.
Return value
The nonce used in the request.
3 calls to SearchApiAcquiaSearchConnection::prepareRequest()
- SearchApiAcquiaSearchConnection::makeServletRequest in includes/
v2/ SearchApiAcquiaSearchConnection.php - Make a request to a servlet (a path) that's not a standard path.
- SearchApiAcquiaSearchConnection::sendRawGet in includes/
v2/ SearchApiAcquiaSearchConnection.php - Central method for making a GET operation against this Solr Server
- SearchApiAcquiaSearchConnection::sendRawPost in includes/
v2/ SearchApiAcquiaSearchConnection.php - Central method for making a POST operation against this Solr Server
File
- includes/
v2/ SearchApiAcquiaSearchConnection.php, line 82
Class
- SearchApiAcquiaSearchConnection
- Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.
Code
public function prepareRequest(&$url, &$options, $use_data = TRUE) {
// Add a unique request ID to the URL.
$id = uniqid();
if (!stristr($url, '?')) {
$url .= "?";
}
else {
$url .= "&";
}
$url .= 'request_id=' . $id;
// If we're hosted on Acquia, and have an Acquia request ID,
// append it to the request so that we map Solr queries to Acquia search requests.
if (isset($_ENV['HTTP_X_REQUEST_ID'])) {
$xid = empty($_ENV['HTTP_X_REQUEST_ID']) ? '-' : $_ENV['HTTP_X_REQUEST_ID'];
$url .= '&x-request-id=' . rawurlencode($xid);
}
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;
}