Пример #1
0
 public function execute()
 {
     try {
         $socket = rex_socket::factoryUrl($this->getParam('url'));
         if ($this->getParam('http-auth') == '|1|') {
             $socket->addBasicAuthorization($this->getParam('user'), $this->getParam('password'));
         }
         if (($post = $this->getParam('post')) != '') {
             $response = $socket->doPost($post);
         } else {
             $response = $socket->doGet();
         }
         $statusCode = $response->getStatusCode();
         $success = $response->isSuccessful();
         $message = $statusCode . ' ' . $response->getStatusMessage();
         if (in_array($statusCode, [301, 302, 303, 307]) && $this->getParam('redirect', true) && ($location = $response->getHeader('Location'))) {
             // maximal eine Umleitung zulassen
             $this->setParam('redirect', false);
             $this->setParam('url', $location);
             // rekursiv erneut ausfuehren
             $success = $this->execute();
             if ($this->hasMessage()) {
                 $message .= ' -> ' . $this->getMessage();
             } else {
                 $message .= ' -> Unknown error';
             }
         }
         $this->setMessage($message);
         return $success;
     } catch (rex_exception $e) {
         $this->setMessage($e->getMessage());
         return false;
     }
 }
Пример #2
0
 public static function getArchive($url)
 {
     global $I18N;
     try {
         $socket = rex_socket::factoryUrl($url);
         $response = $socket->doGet();
         if ($response->isOk()) {
             $filename = basename($url);
             $file = rex_path::addonCache('install', md5($filename) . '.' . rex_file::extension($filename));
             $response->writeBodyTo($file);
             return $file;
         }
     } catch (rex_socket_exception $e) {
     }
     throw new rex_install_functional_exception($I18N->msg('install_archive_unreachable'));
 }
Пример #3
0
 public function testFactoryUrlProxy()
 {
     rex::setProperty('socket_proxy', 'proxy.example.com:8888');
     $socket = rex_socket::factoryUrl('www.example.com');
     $this->assertEquals('rex_socket_proxy', get_class($socket));
 }