public function testResult_full() { $resp = $this->_cms['http']->request($this->_url, array(), array('response' => AbstractHttp::RESULT_FULL)); $data = new JSON($resp); isSame('{"key":"value"}', $data->get('body')); isSame('foo', $data->find('headers.x-custom-header')); isSame(200, $data->find('code')); }
/** * Get JSON from php://input stream * * @param string $name * @param null $default * @param null $filters * @return Data|mixed */ public function getJSON($name = null, $default = null, $filters = null) { static $data; $input = null; if (null === $data) { if ($this->getHeader('Content-Type', 'text/html', 'low') === 'application/json') { $input = file_get_contents('php://input'); } $data = new JSON($input); } if (null === $name) { return $data; } $result = $data->find($name, $default, $filters); return $result; }