public function __construct($url, $callback = null)
 {
     register_shutdown_function(array(&$this, "__destruct"));
     $options = array(CURLOPT_USERAGENT => sfConfig::get('app_version_name') . ' (' . sfConfig::get('app_version_rev') . ' ' . sfConfig::get('app_version_comment') . ') ' . sfConfig::get('app_version_url'));
     // todo abstact this out
     $this->original_url = $url;
     $original_name = preg_replace('#^.*/#', '', $this->original_url);
     // we'll need to do this for redirects fixme
     $this->b = $b = new disconnectedCurl($url, $options);
     // probably want to have a way to gather statistics here
     try {
         $b->run($callback);
         // we should HEAD this first
     } catch (Exception $e) {
         throw limeException::createFromException($e, 'curl');
     }
     if ($b->isRunning()) {
         throw new limeException('curl', 'still running');
     }
     $mime_type = $b->getHeader('Content-Type');
     // of course we shouldn't trust people to have their servers configured right; sigh todo
     $mime_type = preg_replace('/;.*$/', '', $mime_type);
     // remove stuff after the semicolon delimiter "charset=UTF-8" etc
     parent::__construct($original_name, $mime_type, $b->getFile(), filesize($b->getFile()));
 }
 public function testSideload()
 {
     if (!function_exists('curl_init')) {
         throw new limeException('curl', 'CURL support is not compiled/loaded in PHP.');
     }
     $request = sfContext::getInstance()->getRequest();
     $url = 'http://' . $request->getHost() . $request->getRelativeUrlRoot() . '/' . 'robots.txt';
     // fixme
     $b = new disconnectedCurl($url);
     try {
         $b->run();
         return true;
     } catch (Exception $e) {
         throw limeException::createFromException($e, 'sideload');
     }
 }