Ejemplo n.º 1
0
 public function execute(AbstractAction $action)
 {
     try {
         $uri = $action->uri();
         $file = $action->file();
         if ($uri == null) {
             throw new ProxyException("Invalid URI");
         }
         $url = $this->prepareRequestUrl($uri);
         $query = $uri->getQuery();
         $response = $this->makeRequest($url, $query, $file);
         $this->checkCode($response['code']);
         if (empty($response['output'])) {
             throw new ProxyException('Error fetching remote content empty');
         }
     } catch (\Exception $e) {
         throw new ProxyException($e->getMessage());
     }
     return $response['output'];
 }
Ejemplo n.º 2
0
 public function execute(AbstractAction $action)
 {
     try {
         $uri = $action->uri();
         $file = $action->file();
         if ($uri == null) {
             throw new ProxyException("Invalid URI");
         }
         $method = $action->getMethod();
         $url = $this->prepareRequestUrl($uri);
         $query = $uri->getQuery();
         $response = $this->makeRequest($method, $url, $query, $file, $action->isContacts());
         if (!$action->isContacts()) {
             $this->checkCode($response['code']);
         }
         $notDeleteOrHead = !in_array($method, array(AbstractAction::METHOD_DELETE, AbstractAction::METHOD_HEAD));
         if ($notDeleteOrHead and empty($response['output'])) {
             throw new ProxyException('Error fetching remote content empty');
         }
     } catch (\Exception $e) {
         throw new ProxyException($e->getMessage(), 0, $e);
     }
     return $response;
 }