-
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
789c60f
commit 9eb89bd
Showing
3 changed files
with
111 additions
and
8 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
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,43 @@ | ||
--TEST-- | ||
swoole_http_server: trailer | ||
--SKIPIF-- | ||
<?php require __DIR__ . '/../include/skipif.inc'; ?> | ||
--FILE-- | ||
<?php | ||
require __DIR__ . '/../include/bootstrap.php'; | ||
$pm = new SwooleTest\ProcessManager; | ||
$pm->parentFunc = function () use ($pm) { | ||
Swoole\Coroutine\run(function () use ($pm) { | ||
$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', $pm->getFreePort()); | ||
$cli->get('/'); | ||
Assert::eq(md5('hello world'), $cli->headers['content-md5']); | ||
$pm->kill(); | ||
echo "DONE\n"; | ||
}); | ||
}; | ||
$pm->childFunc = function () use ($pm) { | ||
$http = new Swoole\Http\Server('127.0.0.1', $pm->getFreePort()); | ||
|
||
$http->set([ | ||
'worker_num' => 1, | ||
'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->header('trailer', 'Content-MD5'); | ||
$data = 'hello world'; | ||
$response->write($data); | ||
$response->trailer('Content-MD5', md5($data)); | ||
$response->end(); | ||
}); | ||
$http->start(); | ||
}; | ||
$pm->childFirst(); | ||
$pm->run(); | ||
?> | ||
--EXPECT-- | ||
DONE |