/[drupal]/contributions/modules/apachesolr/Drupal_Apache_Solr_Service.php
ViewVC logotype

Diff of /contributions/modules/apachesolr/Drupal_Apache_Solr_Service.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.20.4.2, Fri Oct 23 11:16:30 2009 UTC revision 1.1.2.20.4.3, Thu Nov 5 17:24:43 2009 UTC
# Line 185  class Drupal_Apache_Solr_Service extends Line 185  class Drupal_Apache_Solr_Service extends
185    }    }
186    
187    /**    /**
188       * Make a request to a servlet (a path) that's not a standard path.
189       *
190       * @param string $servlet
191       *   A path to be added to the base Solr path. e.g. 'extract/tika'
192       *
193       * @param array $params
194       *   Any request parameters when constructing the URL.
195       *
196       * @param string $method
197       *   'GET', 'POST', 'PUT', or 'HEAD'.
198       *
199       * @param array $request_headers
200       *   Keyed array of header names and values.  Should include 'Content-Type'
201       *   for POST or PUT.
202       *
203       * @param string $rawPost
204       *   Must be an empty string unless method is POST or PUT.
205       *
206       * @param float $timeout
207       *   Read timeout in seconds or FALSE.
208       *
209       * @return
210       *  Apache_Solr_Response object
211       */
212      public function makeServletRequest($servlet, $params = array(), $method = 'GET', $request_headers = array(), $rawPost = '', $timeout = FALSE) {
213        if ($method == 'GET' || $method == 'HEAD') {
214          // Make sure we are not sending a request body.
215          $rawPost = '';
216        }
217        // Add default params.
218        $params += array(
219          'wt' => self::SOLR_WRITER,
220        );
221    
222        $url = $this->_constructUrl($servlet, $params);
223        list ($data, $headers) = $this->_makeHttpRequest($url, $method, $request_headers, $rawPost, $timeout);
224        $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
225        $code = (int) $response->getHttpStatus();
226        if ($code != 200) {
227          $message = $response->getHttpStatusMessage();
228          if ($code >= 400 && $code != 403 && $code != 404) {
229            // Add details, like Solr's exception message.
230            $message .= $response->getRawResponse();
231          }
232          throw new Exception('"' . $code . '" Status: ' . $message);
233        }
234        return $response;
235      }
236    
237      /**
238     * Put Luke meta-data from the cache into $this->luke when we instantiate.     * Put Luke meta-data from the cache into $this->luke when we instantiate.
239     *     *
240     * @see Apache_Solr_Service::__construct()     * @see Apache_Solr_Service::__construct()

Legend:
Removed from v.1.1.2.20.4.2  
changed lines
  Added in v.1.1.2.20.4.3

  ViewVC Help
Powered by ViewVC 1.1.2