public static function Nodejs::httpRequest in Node.js integration 7
13 calls to Nodejs::httpRequest()
- Nodejs::addChannel in ./nodejs.module
- Nodejs::addUserToChannel in ./nodejs.module
- Nodejs::checkChannel in ./nodejs.module
- Nodejs::getContentTokenUsers in ./nodejs.module
- Nodejs::healthCheck in ./nodejs.module
... See full list
File
- ./nodejs.module, line 966
Class
- Nodejs
Code
public static function httpRequest($url, $options = array(), $ignore_version = FALSE) {
self::initConfig();
if (!$ignore_version && !self::checkServerVersion()) {
return FALSE;
}
$options += array(
'method' => 'GET',
'headers' => array(),
);
$options['headers'] += array(
'NodejsServiceKey' => self::$config['serviceKey'],
'Content-type' => 'application/json',
);
$response = drupal_http_request(self::$baseUrl . $url, $options);
if (isset($response->error)) {
if (self::$config['log_http_errors']) {
$params = array(
'%code' => $response->code,
'%error' => $response->error,
'%url' => $url,
);
$log_message = 'Error reaching the Node.js server at "%url": [%code] %error.';
if (!empty($options['data'])) {
$params['data'] = $options['data'];
$log_message = 'Error reaching the Node.js server at "%url" with data "%data": [%code] %error.';
}
watchdog('nodejs', $log_message, $params);
}
return FALSE;
}
return json_decode($response->data);
}