Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug: call Request->rawContent/getData after Response->end
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
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
40 changes: 40 additions & 0 deletions
40
tests/swoole_http_server/bug_get_request_data_after_end.phpt
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,40 @@ | ||
--TEST-- | ||
swoole_http_server: bug get request data after response end | ||
--SKIPIF-- | ||
<?php require __DIR__ . '/../include/skipif.inc'; ?> | ||
--FILE-- | ||
<?php | ||
require __DIR__ . '/../include/bootstrap.php'; | ||
$pm = new ProcessManager; | ||
$pm->initRandomData(1); | ||
$pm->parentFunc = function () use ($pm) { | ||
Co\run(function () use ($pm) { | ||
echo httpGetBody("http://127.0.0.1:{$pm->getFreePort()}/", ['data' => $pm->getRandomData()]) . PHP_EOL; | ||
}); | ||
$pm->kill(); | ||
}; | ||
$pm->childFunc = function () use ($pm) { | ||
$http = new Swoole\Http\Server('127.0.0.1', $pm->getFreePort(), SWOOLE_BASE); | ||
$http->set(['log_file' => '/dev/null']); | ||
$http->on('workerStart', function () use ($pm) { | ||
$pm->wakeup(); | ||
}); | ||
$http->on("request", function (Swoole\Http\Request $request, Swoole\Http\Response $response) { | ||
$response->end('OK'); | ||
switch_process(); | ||
var_dump($request->rawContent()); | ||
var_dump($request->getData()); | ||
}); | ||
$http->start(); | ||
}; | ||
$pm->childFirst(); | ||
$pm->run(); | ||
?> | ||
--EXPECTF-- | ||
OK | ||
|
||
Warning: Swoole\Http\Request::rawContent(): %s in %s on line %d | ||
bool(false) | ||
|
||
Warning: Swoole\Http\Request::getData(): %s in %s on line %d | ||
bool(false) |