You are here

protected function Apache_Solr_Service::_sendRawPost in Apache Solr Search 5

Central method for making a post operation against this Solr Server

Parameters

string $url:

string $rawPost:

float $timeout Read timeout in seconds:

string $contentType:

Return value

Apache_Solr_Response

Throws

Exception If a non 200 response status is returned

4 calls to Apache_Solr_Service::_sendRawPost()
Apache_Solr_Service::add in SolrPhpClient/Apache/Solr/Service.php
Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.
Apache_Solr_Service::commit in SolrPhpClient/Apache/Solr/Service.php
Send a commit command. Will be synchronous unless both wait parameters are set to false.
Apache_Solr_Service::delete in SolrPhpClient/Apache/Solr/Service.php
Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document
Apache_Solr_Service::optimize in SolrPhpClient/Apache/Solr/Service.php
Send an optimize command. Will be synchronous unless both wait parameters are set to false.

File

SolrPhpClient/Apache/Solr/Service.php, line 295

Class

Apache_Solr_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 _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8') {

  //ensure content type is correct
  stream_context_set_option($this->_postContext, 'http', 'header', 'Content-Type: ' . $contentType);

  //set the read timeout if specified
  if ($timeout !== FALSE) {
    stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout);
  }

  //set the content
  stream_context_set_option($this->_postContext, 'http', 'content', $rawPost);

  //$http_response_header is set by file_get_contents
  $response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
  if ($response
    ->getHttpStatus() != 200) {
    throw new Exception('"' . $response
      ->getHttpStatus() . '" Status: ' . $response
      ->getHttpStatusMessage(), $response
      ->getHttpStatus());
  }
  return $response;
}