You are here

protected function Drupal_Apache_Solr_Service::_makeHttpRequest in Apache Solr Search 6

Same name and namespace in other branches
  1. 5.2 Drupal_Apache_Solr_Service.php \Drupal_Apache_Solr_Service::_makeHttpRequest()
  2. 6.2 Drupal_Apache_Solr_Service.php \Drupal_Apache_Solr_Service::_makeHttpRequest()
4 calls to Drupal_Apache_Solr_Service::_makeHttpRequest()
Drupal_Apache_Solr_Service::makeServletRequest in ./Drupal_Apache_Solr_Service.php
Make a request to a servlet (a path) that's not a standard path.
Drupal_Apache_Solr_Service::ping in ./Drupal_Apache_Solr_Service.php
Call the /admin/ping servlet, to test the connection to the server.
Drupal_Apache_Solr_Service::_sendRawGet in ./Drupal_Apache_Solr_Service.php
Central method for making a get operation against this Solr Server
Drupal_Apache_Solr_Service::_sendRawPost in ./Drupal_Apache_Solr_Service.php
Central method for making a post operation against this Solr Server

File

./Drupal_Apache_Solr_Service.php, line 352

Class

Drupal_Apache_Solr_Service

Code

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);
  }
  if (!isset($result->code) || $result->code < 0) {
    $result->code = 0;
    $result->status_message = 'Request failed';
  }
  if (isset($result->error)) {
    $result->status_message .= ': ' . check_plain($result->error);
  }
  if (!isset($result->data)) {
    $result->data = '';
  }
  $headers[] = "{$result->protocol} {$result->code} {$result->status_message}";
  if (isset($result->headers)) {
    foreach ($result->headers as $name => $value) {
      $headers[] = "{$name}: {$value}";
    }
  }
  return array(
    $result->data,
    $headers,
  );
}