You are here

protected function Acquia_Search_Service::_sendRawGet in Acquia Search 6

Central method for making a get operation against this Solr Server

See also

Drupal_Apache_Solr_Service::_sendRawGet()

File

./Acquia_Search_Service.php, line 49

Class

Acquia_Search_Service
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

Code

protected function _sendRawGet($url, $timeout = FALSE) {
  $id = $this
    ->add_request_id($url);
  list($cookie, $nonce) = acquia_search_auth_cookie($url);
  if (empty($cookie)) {
    throw new Exception('Invalid authentication string - subscription keys expired or missing.');
  }
  $request_headers = array(
    'Cookie' => $cookie,
    'User-Agent' => 'acquia_search/' . ACQUIA_SEARCH_VERSION,
  );
  list($data, $headers) = $this
    ->_makeHttpRequest($url, 'GET', $request_headers, '', $timeout);
  $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
  $hmac = acquia_search_extract_hmac($headers);
  $code = (int) $response
    ->getHttpStatus();
  if ($code != 200) {
    $message = $response
      ->getHttpStatusMessage() . "\n request ID: {$id} \n";
    if ($code >= 400 && $code != 403 && $code != 404) {

      // Add details, like Solr's exception message.
      $message .= $response
        ->getRawResponse();
    }
    throw new Exception('"' . $code . '" Status: ' . $message);
  }
  elseif (!acquia_search_valid_response($hmac, $nonce, $data)) {
    throw new Exception('Authentication of search content failed url: ' . $url);
  }
  return $response;
}