Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Http\Response->isWritable(): bool
Check if a HTTP response is closed or writable.
Used to check if a response object is still writable, this is useful for when you don't know if the request has ended or has been detached, you can use this method to check.
Since v4.6.0
<?php
$server = new Server('127.0.0.1', 9501);
$server->on('Request', function(Swoole\Http\Request $request, Swoole\Http\Response $response)
{
// true
var_dump($response->isWritable());
$response->end('hello');
// false
var_dump($response->isWritable());
// http response is unavailable (it has been ended or detached)
$response->setStatusCode(403);
});
$server->start();