protected function ServicesClientConnection::httpRequest in Services Client 7
Same name and namespace in other branches
- 7.2 services_client_connection/include/connection.inc \ServicesClientConnection::httpRequest()
Make low level HTTP request which allows to make calls to non-services REST only endpoints.
Parameters
$method: HTTP method - GET, POST, DELETE, PUT
$path: Requested path
$query: GET query parameters
$data: DATA that needs to be posted - all except GET requests
$headers: Optionally additional HTTP headers
6 calls to ServicesClientConnection::httpRequest()
- ServicesClientConnection::rawDelete in services_client_connection/
include/ connection.inc - HTTP DELETE method
- ServicesClientConnection::rawGet in services_client_connection/
include/ connection.inc - HTTP GET method
- ServicesClientConnection::rawOptions in services_client_connection/
include/ connection.inc - HTTP OPTIONS method
- ServicesClientConnection::rawPatch in services_client_connection/
include/ connection.inc - HTTP PATCH method
- ServicesClientConnection::rawPost in services_client_connection/
include/ connection.inc - HTTP POST method
File
- services_client_connection/
include/ connection.inc, line 421 - Main services client connection class which exposes simple API
Class
- ServicesClientConnection
- @file Main services client connection class which exposes simple API
Code
protected function httpRequest($method, $path, $query = array(), $data = array(), $headers = array()) {
// Raw HTTP requests will only work with REST Request plugin
if (!is_a($this->server, 'ServicesClientConnectionRestServer')) {
throw new ServicesClientConnectionException(t("Raw HTTP requests require ServicesClientConnectionRestServer plugin."));
}
// Normalize http method
$method = strtoupper($method);
// Some methods shoudln't carry any data
if (!empty($data) && in_array($method, array(
'GET',
'DELETE',
'OPTIONS',
))) {
throw new ServicesClientConnectionException(t("Method @name can't carry data in request body, only in query.", array(
'@name' => $method,
)));
}
$this->http_request = $this
->createRequest(array(
'http_method' => $method,
'url' => $path,
'query' => $query,
'data' => $data,
'http_headers' => $headers,
));
return $this
->processRequest()->data;
}