You are here

protected function Drupal_Apache_Solr_Service::_sendRawPost in Apache Solr Search 6

Same name and namespace in other branches
  1. 5.2 Drupal_Apache_Solr_Service.php \Drupal_Apache_Solr_Service::_sendRawPost()
  2. 6.2 Drupal_Apache_Solr_Service.php \Drupal_Apache_Solr_Service::_sendRawPost()

Central method for making a post operation against this Solr Server

See also

Apache_Solr_Service::_sendRawPost()

1 call to Drupal_Apache_Solr_Service::_sendRawPost()
Drupal_Apache_Solr_Service::search in ./Drupal_Apache_Solr_Service.php
Switch to POST for search if resultant query string is too long.

File

./Drupal_Apache_Solr_Service.php, line 336

Class

Drupal_Apache_Solr_Service

Code

protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8') {
  $request_headers = array(
    'Content-Type' => $contentType,
  );
  list($data, $headers) = $this
    ->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
  $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
  $code = (int) $response
    ->getHttpStatus();
  if ($code != 200) {
    $message = $response
      ->getHttpStatusMessage();
    if ($code >= 400 && $code != 403 && $code != 404) {

      // Add details, like Solr's exception message.
      $message .= $response
        ->getRawResponse();
    }
    throw new Exception('"' . $code . '" Status: ' . $message);
  }
  return $response;
}