protected function fetch($origin, $fileUrl, $progress, $options, $exec)
 {
     do {
         $this->retry = false;
         $request = new Aspects\HttpGetRequest($origin, $fileUrl, $this->io);
         $request->setSpecial(array('github' => $this->config->get('github-domains') ?: array(), 'gitlab' => $this->config->get('gitlab-domains') ?: array()));
         $this->onPreDownload = Factory::getPreEvent($request);
         $this->onPostDownload = Factory::getPostEvent($request);
         if ($this->degradedMode) {
             $this->onPreDownload->attach(new Aspects\AspectDegradedMode());
         }
         $options += $this->options;
         // override
         if ('github' === $request->special && isset($options['github-token'])) {
             $request->query['access_token'] = $options['github-token'];
         }
         if ('gitlab' === $request->special && isset($options['gitlab-token'])) {
             $request->query['access_token'] = $options['gitlab-token'];
         }
         if ($this->io->isDebug()) {
             $this->io->write('Downloading ' . $fileUrl);
         }
         if ($progress) {
             $this->io->write("    Downloading: <comment>Connecting...</comment>", false);
             $request->curlOpts[CURLOPT_NOPROGRESS] = false;
             $request->curlOpts[CURLOPT_PROGRESSFUNCTION] = array($this, 'progress');
         } else {
             $request->curlOpts[CURLOPT_NOPROGRESS] = true;
             $request->curlOpts[CURLOPT_PROGRESSFUNCTION] = null;
         }
         $this->onPreDownload->notify();
         $opts = $request->getCurlOpts();
         if (empty($opts[CURLOPT_USERPWD])) {
             unset($opts[CURLOPT_USERPWD]);
         }
         $ch = Factory::getConnection($origin, isset($opts[CURLOPT_USERPWD]));
         curl_setopt_array($ch, $opts);
         list($execStatus, $response) = $exec($ch, $request);
     } while ($this->retry);
     if ($progress) {
         $this->io->overwrite("    Downloading: <comment>100%</comment>");
     }
     return $execStatus;
 }
 /**
  * @param string $origin
  * @param string $fileUrl
  * @param boolean $progress
  * @param \Closure $exec
  */
 protected function fetch($origin, $fileUrl, $progress, $options, $exec)
 {
     do {
         $this->_retry = false;
         $request = Factory::getHttpGetRequest($origin, $fileUrl, $this->io, $this->config, $this->pluginConfig);
         $this->onPreDownload = Factory::getPreEvent($request);
         $this->onPostDownload = Factory::getPostEvent($request);
         $options += $this->options;
         $request->processRFSOption($options);
         if ($this->io->isDebug()) {
             $this->io->write('Downloading ' . $fileUrl);
         }
         if ($progress) {
             $this->io->write("    Downloading: <comment>Connecting...</comment>", false);
             $request->curlOpts[CURLOPT_NOPROGRESS] = false;
             $request->curlOpts[CURLOPT_PROGRESSFUNCTION] = array($this, 'progress');
         } else {
             $request->curlOpts[CURLOPT_NOPROGRESS] = true;
             $request->curlOpts[CURLOPT_PROGRESSFUNCTION] = null;
         }
         $this->onPreDownload->notify();
         $opts = $request->getCurlOpts();
         $ch = Factory::getConnection($origin, isset($opts[CURLOPT_USERPWD]));
         curl_setopt_array($ch, $opts);
         list($execStatus, ) = $exec($ch, $request);
     } while ($this->_retry);
     if ($progress) {
         $this->io->overwrite("    Downloading: <comment>100%</comment>");
     }
     return $execStatus;
 }