/** * Returns the response as json. * * @return mixed */ public function asJson() { if (!$this->isJsonMessage($this->response->headers)) { throw new \RuntimeException('The response is not a valid json response'); } return json_decode($this->response->content(), true); }
protected function response(Response $response) { foreach ($response->headers->all() as $name => $values) { $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name))); foreach ($values as $value) { header($name . ': ' . $value, false, $response->statusCode); } } echo $response->content(); }
protected function response(Response $response) { foreach ($response->headers->all() as $name => $values) { $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name))); foreach ($values as $value) { header($name . ': ' . $value, false, $response->statusCode); } } foreach ($response->cookies as $cookie) { setcookie($cookie->name, $cookie->value, $cookie->expire, $cookie->path, $cookie->domain, $cookie->secure, $cookie->httpOnly); } echo $response->content(); }