Esempio n. 1
0
function chunk(swoole_http_request $request, swoole_http_response $response)
{
    $response->write("<h1>hello world1</h1>");
    //sleep(1);
    $response->write("<h1>hello world2</h1>");
    //sleep(1);
    $response->end();
}
Esempio n. 2
0
 /**
  * @return string
  */
 public function send()
 {
     $this->sendHeaders();
     if ($this->body) {
         $this->swooleResponse->write($this->body);
     }
     $this->swooleResponse->end();
 }
 /**
  * @param ResponseInterface     $response
  * @param \swoole_http_response $swooleResponse
  */
 public function reverseTransform(ResponseInterface $response, \swoole_http_response $swooleResponse)
 {
     foreach (array_keys($response->getHeaders()) as $name) {
         $swooleResponse->header($name, $response->getHeaderLine($name));
     }
     $swooleResponse->status($response->getStatusCode());
     $body = $response->getBody();
     $body->rewind();
     # workaround for https://bugs.php.net/bug.php?id=68948
     while (false === $body->eof() && '' !== ($buffer = $body->read($this->responseBuffer))) {
         $swooleResponse->write($buffer);
     }
     $swooleResponse->end();
 }
Esempio n. 4
0
 function finish($content = null)
 {
     $this->finish = true;
     $this->response->write($content);
     throw new Swoole\Exception\Response();
 }
Esempio n. 5
0
 public function write($data)
 {
     $this->sw->write($data);
     $this->_writeFlag = true;
     return $this;
 }