-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a57869e
commit d58d6c0
Showing
5 changed files
with
1,121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--TEST-- | ||
swoole_http_server: exit function | ||
--SKIPIF-- | ||
<?php | ||
if (PHP_VERSION_ID < 80400) { | ||
require __DIR__ . '/../include/skipif.inc'; | ||
skip('php version 8.4 or higher'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
require __DIR__ . '/../include/bootstrap.php'; | ||
|
||
$pm = new ProcessManager; | ||
$pm->parentFunc = function () use ($pm) { | ||
Co\run(function () use ($pm) { | ||
httpRequest("http://127.0.0.1:{$pm->getFreePort()}"); | ||
}); | ||
|
||
$pm->kill(); | ||
echo "DONE\n"; | ||
}; | ||
|
||
$pm->childFunc = function () use ($pm) { | ||
$http = new Swoole\Http\Server('127.0.0.1', $pm->getFreePort(), SWOOLE_BASE); | ||
$http->on('workerStart', function () use ($pm) { | ||
$pm->wakeup(); | ||
}); | ||
|
||
$http->on('request', function (Swoole\Http\Request $request, Swoole\Http\Response $response) use ($pm) { | ||
try { | ||
exit('Swoole Server exit!!!'); | ||
} catch (Exception $e) { | ||
echo $e->getMessage().PHP_EOL; | ||
} | ||
|
||
try { | ||
exit(); | ||
} catch (Exception $e) { | ||
echo $e->getMessage().PHP_EOL; | ||
} | ||
|
||
try { | ||
exit(400); | ||
} catch (Exception $e) { | ||
echo $e->getStatus().PHP_EOL; | ||
} | ||
$response->end(); | ||
}); | ||
$http->start(); | ||
}; | ||
$pm->childFirst(); | ||
$pm->run(); | ||
?> | ||
--EXPECTF-- | ||
Swoole Server exit!!! | ||
swoole exit | ||
400 | ||
DONE |
Oops, something went wrong.