function testClearingError()
 {
     $error = new SimpleStickyError();
     $error->_setError('Ouch');
     $this->assertTrue($error->isError());
     $error->_clearError();
     $this->assertFalse($error->isError());
 }
Exemple #2
0
 /**
  *    Constructor. Reads and parses the incoming
  *    content and headers.
  *    @param SimpleSocket $socket   Network connection to fetch
  *                                  response text from.
  *    @param SimpleUrl $url         Resource name.
  *    @param mixed $encoding        Record of content sent.
  *    @access public
  */
 function __construct($socket, $url, $encoding)
 {
     parent::__construct();
     $this->url = $url;
     $this->encoding = $encoding;
     $this->sent = $socket->getSent();
     $this->content = false;
     $raw = $this->readAll($socket);
     if ($socket->isError()) {
         $this->setError('Error reading socket [' . $socket->getError() . ']');
         return;
     }
     $this->parse($raw);
 }
Exemple #3
0
 /**
  *    Opens a socket for reading and writing.
  *    @param string $host          Hostname to send request to.
  *    @param integer $port         Port on remote machine to open.
  *    @param integer $timeout      Connection timeout in seconds.
  *    @param integer $block_size   Size of chunk to read.
  *    @access public
  */
 function __construct($host, $port, $timeout, $block_size = 255)
 {
     parent::__construct();
     if (!($this->handle = $this->openSocket($host, $port, $error_number, $error, $timeout))) {
         $this->setError("Cannot open [{$host}:{$port}] with [{$error}] within [{$timeout}] seconds");
         return;
     }
     $this->is_open = true;
     $this->block_size = $block_size;
     SimpleTestCompatibility::setTimeout($this->handle, $timeout);
 }
Exemple #4
0
 /**
  *    Opens a socket for reading and writing.
  *    @param string $host          Hostname to send request to.
  *    @param integer $port         Port on remote machine to open.
  *    @param integer $timeout      Connection timeout in seconds.
  *    @param integer $block_size   Size of chunk to read.
  *    @access public
  */
 public function __construct($host, $port, $timeout, $block_size = 255)
 {
     parent::__construct();
     if (!($this->handle = $this->openSocket($host, $port, $error_number, $error, $timeout))) {
         $this->setError("Cannot open [{$host}:{$port}] with [{$error}] within [{$timeout}] seconds");
         return;
     }
     $this->is_open = true;
     $this->block_size = $block_size;
     stream_set_timeout($this->handle, $timeout, 0);
 }