class AcquiaLiftDrupalHttpClient in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 includes/AcquiaLiftDrupalHttpClient.inc \AcquiaLiftDrupalHttpClient
This is just an OOP wrapper around drupal_http_request.
Hierarchy
- class \AcquiaLiftDrupalHttpClient implements AcquiaLiftDrupalHttpClientInterface
Expanded class hierarchy of AcquiaLiftDrupalHttpClient
1 string reference to 'AcquiaLiftDrupalHttpClient'
- ALProfilesAPI::getAuthHeader in acquia_lift_profiles/
includes/ acquia_lift_profiles.classes.inc - Returns a string to use for the 'Authorization' header.
File
- includes/
acquia_lift.classes.inc, line 1783 - Provides an agent type for Acquia Lift
View source
class AcquiaLiftDrupalHttpClient implements AcquiaLiftDrupalHttpClientInterface {
// Some constants for our timeout values.
const REQUEST_TIMEOUT_VALUE_GET = 8.0;
const REQUEST_TIMEOUT_VALUE_DEFAULT = 15.0;
protected function encodeBody($body) {
if (is_string($body)) {
$data = $body;
}
else {
$data = drupal_json_encode($body);
}
return $data;
}
/**
* Implements AcquiaLiftDrupalHttpClientInterface::get().
*/
public function get($uri = NULL, $headers = NULL, array $options = array()) {
$headers = $headers ? $headers : array();
$options += array(
'timeout' => self::REQUEST_TIMEOUT_VALUE_GET,
);
$options = array(
'method' => 'GET',
'headers' => $headers,
) + $options;
return drupal_http_request($uri, $options);
}
/**
* Implements AcquiaLiftDrupalHttpClientInterface::put().
*/
public function put($uri = NULL, $headers = NULL, $body = NULL, array $options = array()) {
$data = $body === NULL ? NULL : $this
->encodeBody($body);
$headers = $headers ? $headers : array();
$options += array(
'timeout' => self::REQUEST_TIMEOUT_VALUE_DEFAULT,
);
$options = array(
'method' => 'PUT',
'data' => $data,
'headers' => $headers,
) + $options;
return drupal_http_request($uri, $options);
}
/**
* Implements AcquiaLiftDrupalHttpClientInterface::post().
*/
public function post($uri = NULL, $headers = NULL, $body = NULL, array $options = array()) {
$data = $body ? $this
->encodeBody($body) : NULL;
$headers = $headers ? $headers : array();
$options += array(
'timeout' => self::REQUEST_TIMEOUT_VALUE_DEFAULT,
);
$options = array(
'method' => 'POST',
'data' => $data,
'headers' => $headers,
) + $options;
return drupal_http_request($uri, $options);
}
/**
* Implements AcquiaLiftDrupalHttpClientInterface::delete().
*/
public function delete($uri = null, $headers = null, $body = null, array $options = array()) {
$data = $body ? $this
->encodeBody($body) : NULL;
$headers = $headers ? $headers : array();
$options += array(
'timeout' => self::REQUEST_TIMEOUT_VALUE_DEFAULT,
);
$options = array(
'method' => 'DELETE',
'data' => $data,
'headers' => $headers,
) + $options;
return drupal_http_request($uri, $options);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiaLiftDrupalHttpClient:: |
public | function |
Implements AcquiaLiftDrupalHttpClientInterface::delete(). Overrides AcquiaLiftDrupalHttpClientInterface:: |
|
AcquiaLiftDrupalHttpClient:: |
protected | function | ||
AcquiaLiftDrupalHttpClient:: |
public | function |
Implements AcquiaLiftDrupalHttpClientInterface::get(). Overrides AcquiaLiftDrupalHttpClientInterface:: |
|
AcquiaLiftDrupalHttpClient:: |
public | function |
Implements AcquiaLiftDrupalHttpClientInterface::post(). Overrides AcquiaLiftDrupalHttpClientInterface:: |
|
AcquiaLiftDrupalHttpClient:: |
public | function |
Implements AcquiaLiftDrupalHttpClientInterface::put(). Overrides AcquiaLiftDrupalHttpClientInterface:: |
|
AcquiaLiftDrupalHttpClient:: |
constant | |||
AcquiaLiftDrupalHttpClient:: |
constant |