Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\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(OpenSwoole\Http\Request $request, OpenSwoole\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();