public function test_json_encode() { $result = Raven_Compat::json_encode(array('foo' => array('bar' => 1))); $this->assertEquals($result, '{"foo":{"bar":1}}'); $result = Raven_Compat::_json_encode(array('foo' => array('bar' => 1))); $this->assertEquals($result, '{"foo":{"bar":1}}'); }
public function test_json_encode() { $result = Raven_Compat::json_encode(array('foo' => array('bar' => 1))); $this->assertEquals('{"foo":{"bar":1}}', $result); $result = Raven_Compat::_json_encode(array('foo' => array('bar' => 1))); $this->assertEquals('{"foo":{"bar":1}}', $result); $result = Raven_Compat::_json_encode(array(1, 2, 3, 4, 'foo', 'bar')); $this->assertEquals('[1,2,3,4,"foo","bar"]', $result); $result = Raven_Compat::_json_encode(array(1, 'foo', 'foobar' => 'bar')); $this->assertEquals('{0:1,1:"foo","foobar":"bar"}', $result); $result = Raven_Compat::_json_encode(array(array())); $this->assertEquals('[[]]', $result); }
public function send($data) { if (!$this->servers) { return; } $message = Raven_Compat::json_encode($data); if (function_exists("gzcompress")) { $message = base64_encode(gzcompress($message)); } foreach ($this->servers as $url) { $client_string = 'raven-php/' . self::VERSION; $timestamp = microtime(true); if ($this->signing) { $signature = $this->get_signature($message, $timestamp, $this->secret_key); } else { $signature = null; } $headers = array('User-Agent' => $client_string, 'X-Sentry-Auth' => $this->get_auth_header($signature, $timestamp, $client_string, $this->public_key), 'Content-Type' => 'application/octet-stream'); $this->send_remote($url, $message, $headers); } }
/** * Wrapper to handle encoding and sending data to all defined Sentry servers * * @param array $data Associative array of data to log */ public function send($data) { if (is_callable($this->send_callback) && !call_user_func($this->send_callback, $data)) { // if send_callback returns falsely, end native send return; } if (!$this->servers) { return; } $message = Raven_Compat::json_encode($data); if (function_exists("gzcompress")) { $message = gzcompress($message); } $message = base64_encode($message); // PHP's builtin curl_* function are happy without this, but the exec method requires it foreach ($this->servers as $url) { $client_string = 'raven-php/' . self::VERSION; $timestamp = microtime(true); $headers = array('User-Agent' => $client_string, 'X-Sentry-Auth' => $this->get_auth_header($timestamp, $client_string, $this->public_key, $this->secret_key), 'Content-Type' => 'application/octet-stream'); $this->send_remote($url, $message, $headers); } }
public function send($data) { $message = base64_encode(gzcompress(Raven_Compat::json_encode($data))); foreach ($this->servers as $url) { $timestamp = microtime(true); $signature = $this->get_signature($message, $timestamp, $this->secret_key); $headers = array('X-Sentry-Auth' => $this->get_auth_header($signature, $timestamp, 'raven-php/0.1', $this->public_key), 'Content-Type' => 'application/octet-stream'); $this->send_remote($url, $message, $headers); } }