You are here

public function GuzzleConnectionDebug::performRequest in Elasticsearch Connector 7

Same name and namespace in other branches
  1. 7.5 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::performRequest()
  2. 7.2 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::performRequest()

Perform an HTTP request on the cluster

Parameters

string $method HTTP method to use for request:

string $uri HTTP URI to use for request:

null|string $params Optional URI parameters:

null|string $body Optional request body:

array $options:

Return value

array

File

modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc, line 101

Class

GuzzleConnectionDebug

Namespace

Elasticsearch\Connections

Code

public function performRequest($method, $uri, $params = null, $body = null, $options = array()) {
  $uri = $this
    ->getURI($uri, $params);
  $options += $this->connectionOpts;
  $request = $this
    ->buildGuzzleRequest($method, $uri, $body, $options);
  self::$debugOutput[] = array(
    'request' => array(
      'method' => $method,
      'uri' => $uri,
      'params' => $params,
      'body' => $body,
      'options' => $options,
    ),
  );
  $time = time();
  $response = $this
    ->sendRequest($request, $body);
  self::$debugOutput[] = array(
    'response' => array(
      'status' => $response
        ->getStatusCode(),
      'text' => $response
        ->getBody(true),
      'info' => $response
        ->getInfo(),
    ),
  );
  return array(
    'status' => $response
      ->getStatusCode(),
    'text' => $response
      ->getBody(true),
    'info' => $response
      ->getInfo(),
  );
}