PHPDaemon\HTTPRequest\Generic::out PHP Method

out() public method

Output some data
public out ( string $s, boolean $flush = true ) : boolean
$s string String to out
$flush boolean ob_flush?
return boolean Success
    public function out($s, $flush = true)
    {
        if ($flush) {
            if (!Daemon::$obInStack) {
                // preventing recursion
                ob_flush();
            }
        }
        if ($this->aborted) {
            return false;
        }
        if (!isset($this->upstream)) {
            return false;
        }
        $l = mb_orig_strlen($s);
        $this->responseLength += $l;
        $this->ensureSentHeaders();
        if ($this->attrs->chunked) {
            for ($o = 0; $o < $l;) {
                $c = min($this->upstream->pool->config->chunksize->value, $l - $o);
                $chunk = dechex($c) . "\r\n" . ($c === $l ? $s : mb_orig_substr($s, $o, $c)) . "\r\n";
                if ($this->sendfp) {
                    $this->sendfp->write($chunk);
                } else {
                    $this->upstream->requestOut($this, $chunk);
                }
                $o += $c;
            }
            return true;
        } else {
            if ($this->sendfp) {
                $this->sendfp->write($s);
                return true;
            }
            if (Daemon::$compatMode) {
                echo $s;
                return true;
            }
            return $this->upstream->requestOut($this, $s);
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * Output some data
  * @param  string  $s     String to out
  * @param  boolean $flush
  * @return boolean        Success
  */
 public function out($s, $flush = true)
 {
     if ($this->heartbeatTimer !== null) {
         Timer::setTimeout($this->heartbeatTimer);
     }
     return parent::out($s, $flush);
 }
All Usage Examples Of PHPDaemon\HTTPRequest\Generic::out