Index: xc_solr/SolrPhpClient/Apache/Solr/Service/BalancerXc.php
===================================================================
--- xc_solr/SolrPhpClient/Apache/Solr/Service/BalancerXc.php	(revision 101)
+++ xc_solr/SolrPhpClient/Apache/Solr/Service/BalancerXc.php	(working copy)
@@ -37,7 +37,7 @@
 
 // See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1)
 // Doesn't follow typical include path conventions, but is more convenient for users
-require_once(dirname(dirname(__FILE__)) . '/ServiceXc.php');
+require_once(dirname(dirname(__FILE__)) . '/Drupal_Apache_Solr_ServiceXc.php');
 
 /**
  * Reference Implementation for using multiple Solr services in a distribution. Functionality
@@ -74,7 +74,7 @@
 	 */
 	static public function escape($value)
 	{
-		return Apache_Solr_ServiceXc::escape($value);
+		return Drupal_Apache_Solr_ServiceXc::escape($value);
 	}
 
 	/**
@@ -85,7 +85,7 @@
 	 */
 	static public function escapePhrase($value)
 	{
-		return Apache_Solr_ServiceXc::escapePhrase($value);
+		return Drupal_Apache_Solr_ServiceXc::escapePhrase($value);
 	}
 
 	/**
@@ -96,7 +96,7 @@
 	 */
 	static public function phrase($value)
 	{
-		return Apache_Solr_ServiceXc::phrase($value);
+		return Drupal_Apache_Solr_ServiceXc::phrase($value);
 	}
 
 	/**
@@ -158,7 +158,7 @@
 	 */
 	public function addReadService($service)
 	{
-		if ($service instanceof Apache_Solr_ServiceXc)
+		if ($service instanceof Drupal_Apache_Solr_ServiceXc)
 		{
 			$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
 
@@ -190,7 +190,7 @@
 	{
 		$id = '';
 
-		if ($service instanceof Apache_Solr_ServiceXc)
+		if ($service instanceof Drupal_Apache_Solr_ServiceXc)
 		{
 			$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
 		}
@@ -226,7 +226,7 @@
 	 */
 	public function addWriteService($service)
 	{
-		if ($service instanceof Apache_Solr_ServiceXc)
+		if ($service instanceof Drupal_Apache_Solr_ServiceXc)
 		{
 			$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
 
@@ -258,7 +258,7 @@
 	{
 		$id = '';
 
-		if ($service instanceof Apache_Solr_ServiceXc)
+		if ($service instanceof Drupal_Apache_Solr_ServiceXc)
 		{
 			$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
 		}
@@ -288,7 +288,7 @@
 	 * Iterate through available read services and select the first with a ping
 	 * that satisfies configured timeout restrictions (or the default)
 	 *
-	 * @return Apache_Solr_ServiceXc
+	 * @return Drupal_Apache_Solr_ServiceXc
 	 *
 	 * @throws Exception If there are no read services that meet requirements
 	 */
@@ -316,7 +316,7 @@
 				if (is_array($service))
 				{
 					//convert the array definition to a client object
-					$service = new Apache_Solr_ServiceXc($service['host'], $service['port'], $service['path']);
+					$service = new Drupal_Apache_Solr_ServiceXc($service['host'], $service['port'], $service['path']);
 					$this->_readableServices[$id] = $service;
 				}
 
@@ -336,7 +336,7 @@
 	 * Iterate through available write services and select the first with a ping
 	 * that satisfies configured timeout restrictions (or the default)
 	 *
-	 * @return Apache_Solr_ServiceXc
+	 * @return Drupal_Apache_Solr_ServiceXc
 	 *
 	 * @throws Exception If there are no write services that meet requirements
 	 */
@@ -369,7 +369,7 @@
 				if (is_array($service))
 				{
 					//convert the array definition to a client object
-					$service = new Apache_Solr_ServiceXc($service['host'], $service['port'], $service['path']);
+					$service = new Drupal_Apache_Solr_ServiceXc($service['host'], $service['port'], $service['path']);
 					$this->_writeableServices[$id] = $service;
 				}
 
@@ -391,7 +391,7 @@
 	 * reached.   This will allow for increased reliability with heavily loaded
 	 * server(s).
 	 *
-	 * @return Apache_Solr_ServiceXc
+	 * @return Drupal_Apache_Solr_ServiceXc
 	 *
 	 * @throws Exception If there are no write services that meet requirements
 	 */
@@ -414,7 +414,7 @@
 					if (is_array($service))
 					{
 						//convert the array definition to a client object
-						$service = new Apache_Solr_ServiceXc($service['host'], $service['port'], $service['path']);
+						$service = new Drupal_Apache_Solr_ServiceXc($service['host'], $service['port'], $service['path']);
 						$this->_writeableServices[$id] = $service;
 					}
 
Index: xc_solr/SolrPhpClient/Apache/Solr/ServiceXc.php
===================================================================
--- xc_solr/SolrPhpClient/Apache/Solr/ServiceXc.php	(revision 101)
+++ xc_solr/SolrPhpClient/Apache/Solr/ServiceXc.php	(working copy)
@@ -47,7 +47,7 @@
  * Example Usage:
  * <code>
  * ...
- * $solr = new Apache_Solr_ServiceXc(); //or explicitly new Apache_Solr_ServiceXc('localhost', 8180, '/solr')
+ * $solr = new Drupal_Apache_Solr_ServiceXc(); //or explicitly new Drupal_Apache_Solr_ServiceXc('localhost', 8180, '/solr')
  *
  * if ($solr->ping())
  * {
@@ -131,7 +131,8 @@
 
 	/**
 	 * How NamedLists should be formatted in the output.  This specifically effects facet counts. Valid values
-	 * are {@link Apache_Solr_ServiceXc::NAMED_LIST_MAP} (default) or {@link Apache_Solr_ServiceXc::NAMED_LIST_FLAT}.
+	 * are {@link Drupal_Apache_Solr_ServiceXc::NAMED_LIST_MAP} (default) or
+   * {@link Drupal_Apache_Solr_ServiceXc::NAMED_LIST_FLAT}.
 	 *
 	 * @var string
 	 */
@@ -170,7 +171,7 @@
 	/**
 	 * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
 	 *
-	 * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_ServiceXc::escapePhrase()} instead
+	 * NOTE: inside a phrase fewer characters need escaped, use {@link Drupal_Apache_Solr_ServiceXc::escapePhrase()} instead
 	 *
 	 * @param string $value
 	 * @return string
@@ -530,12 +531,12 @@
 	{
 		switch ((string) $namedListTreatment)
 		{
-			case Apache_Solr_ServiceXc::NAMED_LIST_FLAT:
-				$this->_namedListTreatment = Apache_Solr_ServiceXc::NAMED_LIST_FLAT;
+			case Drupal_Apache_Solr_ServiceXc::NAMED_LIST_FLAT:
+				$this->_namedListTreatment = Drupal_Apache_Solr_ServiceXc::NAMED_LIST_FLAT;
 				break;
 
-			case Apache_Solr_ServiceXc::NAMED_LIST_MAP:
-				$this->_namedListTreatment = Apache_Solr_ServiceXc::NAMED_LIST_MAP;
+			case Drupal_Apache_Solr_ServiceXc::NAMED_LIST_MAP:
+				$this->_namedListTreatment = Drupal_Apache_Solr_ServiceXc::NAMED_LIST_MAP;
 				break;
 
 			default:
@@ -927,4 +928,4 @@
 		return $this->_sendRawGet($url . $this->_queryDelimiter . $queryString, 
 		  FALSE, $verbose);
 	}
-}
\ No newline at end of file
+}
Index: xc_solr/SolrPhpClient/Apache/Solr/Drupal_Apache_Solr_ServiceXc.php
===================================================================
--- xc_solr/SolrPhpClient/Apache/Solr/Drupal_Apache_Solr_ServiceXc.php	(revision 0)
+++ xc_solr/SolrPhpClient/Apache/Solr/Drupal_Apache_Solr_ServiceXc.php	(revision 0)
@@ -0,0 +1,127 @@
+<?php
+require_once 'ServiceXc.php';
+
+class Drupal_Apache_Solr_ServiceXc extends Apache_Solr_ServiceXc {
+
+  /**
+   * Call the /admin/ping servlet, to test the connection to the server.
+   *
+   * @param $timeout
+   *   maximum time to wait for ping in seconds, -1 for unlimited (default 2).
+   * @return
+   *   (float) seconds taken to ping the server, FALSE if timeout occurs.
+   */
+  public function ping($timeout = 2) {
+    $start = microtime(TRUE);
+
+    if ($timeout <= 0.0) {
+      $timeout = -1;
+    }
+    // Attempt a HEAD request to the solr ping url.
+    list($data, $headers) = $this->_makeHttpRequest($this->_pingUrl, 'HEAD', array(), NULL, $timeout);
+    $response = new Apache_Solr_ResponseXc($data, $headers);
+
+    if ($response->getHttpStatus() == 200) {
+      // Add 0.1 ms to the ping time so we never return 0.0.
+      return microtime(TRUE) - $start + 0.0001;
+    }
+    else {
+      return FALSE;
+    }
+  }
+
+  /**
+   * @see Apache_Solr_Service::__construct()
+   */
+  public function __construct($host = 'localhost', $port = 8180, $path = '/solr/') {
+    parent::__construct($host, $port, $path);
+  }
+
+  /**
+   * Central method for making a get operation against this Solr Server
+   *
+   * @see Apache_Solr_Service::_sendRawGet()
+   */
+  protected function _sendRawGet($url, $timeout = FALSE) {
+    list($data, $headers) = $this->_makeHttpRequest($url, 'GET', array(), '', $timeout);
+    $response = new Apache_Solr_ResponseXc($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;
+  }
+
+  /**
+   * Central method for making a post operation against this Solr Server
+   *
+   * @see Apache_Solr_Service::_sendRawPost()
+   */
+  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_ResponseXc($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;
+  }
+
+  protected function _makeHttpRequest($url, $method = 'GET', $headers = array(), $content = '', $timeout = FALSE) {
+    // Set a response timeout
+    if ($timeout) {
+      $default_socket_timeout = ini_set('default_socket_timeout', $timeout);
+    }
+    $result = drupal_http_request($url, $headers, $method, $content);
+    // Restore the response timeout
+    if ($timeout) {
+      ini_set('default_socket_timeout', $default_socket_timeout);
+    }
+
+    // This will no longer be needed after http://drupal.org/node/345591 is committed
+    $responses = array(
+      0 => 'Request failed',
+      100 => 'Continue', 101 => 'Switching Protocols',
+      200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content',
+      300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect',
+      400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed',
+      500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported'
+    );
+
+    if (!isset($result->code) || $result->code < 0) {
+      $result->code = 0;
+    }
+
+    if (isset($result->error)) {
+      $responses[0] .= ': ' . check_plain($result->error);
+    }
+
+    if (!isset($result->data)) {
+      $result->data = '';
+    }
+
+    if (!isset($responses[$result->code])) {
+      $result->code = floor($result->code / 100) * 100;
+    }
+
+    $protocol = "HTTP/1.1";
+    $headers[] = "{$protocol} {$result->code} {$responses[$result->code]}";
+    if (isset($result->headers)) {
+      foreach ($result->headers as $name => $value) {
+        $headers[] = "$name: $value";
+      }
+    }
+    return array($result->data, $headers);
+  }
+}
Index: xc_solr/xc_solr.module
===================================================================
--- xc_solr/xc_solr.module	(revision 101)
+++ xc_solr/xc_solr.module	(working copy)
@@ -13,7 +13,7 @@
  */
 require_once 'SolrPhpClient/Apache/Solr/DocumentXc.php';
 require_once 'SolrPhpClient/Apache/Solr/ResponseXc.php';
-require_once 'SolrPhpClient/Apache/Solr/ServiceXc.php';
+require_once 'SolrPhpClient/Apache/Solr/Drupal_Apache_Solr_ServiceXc.php';
 require_once 'xc_solr_date.inc';
 
 /**
@@ -1384,7 +1384,7 @@
       // the Solr object
       $solr = $_xc_solr_obj[$context['sandbox']['solr_id']];
       // handling if Solr is not valid
-      if(empty($solr) || get_class($solr) != 'Apache_Solr_ServiceXc') {
+      if(empty($solr) || get_class($solr) != 'Drupal_Apache_Solr_ServiceXc') {
         $context['results']['error'] = t('Location is not refers to a valid Solr server');
         $context['finished'] = 1;
         $has_solr = FALSE;
@@ -2145,7 +2145,7 @@
   // Get the servers
   $_xc_solr_obj = array();
   foreach (xc_solr_get_servers() as $solr) {
-    $_xc_solr_obj[$solr->sid] = new Apache_Solr_ServiceXc($solr->host, $solr->port, 
+    $_xc_solr_obj[$solr->sid] = new Drupal_Apache_Solr_ServiceXc($solr->host, $solr->port, 
       $solr->path);
   }
 }
