public function view() { if (empty($this->request->query['link'])) { throw new NotFoundException('Missing link parameter'); } $link = rawurldecode($this->request->query['link']); if (!Validation::url($link)) { throw new NotFoundException('Invalid link'); } $request = new Nodes\Curl($link); $request->exec(); $responseCode = $request->getResponseCode(); if ($responseCode != 200) { throw new NotFoundException('Response code was not 200 OK'); } $this->response->disableCache(); $this->response->type($request->getResponseHeader('content-type')); $this->response->body($request->getResponseBody()); $this->response->send(); $this->_stop(); }
protected function _delete($params) { if (static::$_embedded) { return false; } $request = new \Nodes\Curl(); $request->setOption(CURLOPT_URL, $url = $this->_buildRequestURI($params)); $request->delete(); $responseBody = $request->getResponseBody(); if (isset($responseBody['error'])) { throw new Exception($responseBody['error']['message'], $responseBody['error']['code']); } return $request; }