You are here

protected function ServicesClientConnection::processRequest in Services Client 7.2

Same name and namespace in other branches
  1. 7 services_client_connection/include/connection.inc \ServicesClientConnection::processRequest()

Process HTTP Request. This method will fire all hooks on different plugins which will create final request. Final request is sent to Request plugin.

Parameters

$http_request:

File

services_client_connection/include/connection.inc, line 145
Main services client connection class which exposes simple API

Class

ServicesClientConnection
@file Main services client connection class which exposes simple API

Code

protected function processRequest($http_request = NULL) {

  // Ensure we have proper http request that is processed
  if (empty($http_request)) {
    $http_request = $this->http_request;
  }
  $this->server
    ->prepareRequest($http_request);
  $this->request
    ->prepareRequest($http_request);
  $this->auth
    ->prepareRequest($http_request);
  $this->http_request = $http_request;

  // Allow other modules to react
  drupal_alter('services_client_connection_request', $this->http_request);
  $this->response = $this->request
    ->call($this->http_request);
  $this->server
    ->processResponse($this->response);
  $this->auth
    ->processResponse($this->response);

  // Log data to watchdog
  $this
    ->debug();

  // If response is error generate new exception
  if ($this->response->error_code) {
    throw new ServicesClientConnectionResponseException($this->response, $this->http_request);
  }
  drupal_alter('services_client_connection_response', $this->response, $this->http_request);
  return $this->response;
}