Skip to content

Commit b3883ea

Browse files
committed
Fix test
1 parent efb83c8 commit b3883ea

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

tests/swoole_http_client_coro/http_proxy_with_host_port.phpt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,31 @@ require __DIR__.'/../include/bootstrap.php';
1111

1212
$pm = new SwooleTest\ProcessManager;
1313
$pm->parentFunc = function () use ($pm) {
14-
Co\Run(function () use ($pm) {
15-
$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', $pm->getFreePort());
14+
Co\run(function () use ($pm) {
15+
$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', 1234);
1616
$cli->set([
1717
'timeout' => 30,
18-
'http_proxy_host' => HTTP_PROXY_HOST,
19-
'http_proxy_port' => HTTP_PROXY_PORT,
18+
'http_proxy_host' => '127.0.0.1',
19+
'http_proxy_port' => $pm->getFreePort(),
2020
]);
2121
$cli->setHeaders([
22-
'Host' => '127.0.0.1:'.$pm->getFreePort(),
22+
'Host' => '127.0.0.1:1234',
2323
]);
24-
$result = $cli->get('/');
25-
Assert::assert($result);
26-
Assert::assert('Swoole' === $cli->body);
27-
$cli->close();
24+
$cli->get('/');
2825
$pm->kill();
29-
echo "DONE\n";
3026
});
3127
};
3228

3329
$pm->childFunc = function () use ($pm) {
34-
$server = new Swoole\Http\Server('0.0.0.0', $pm->getFreePort(), SWOOLE_BASE);
35-
$server->set(['log_file' => '/dev/null']);
36-
$server->on('workerStart', function () use ($pm) {
37-
$pm->wakeup();
38-
});
39-
$server->on('request', function (Swoole\Http\Request $request, Swoole\Http\Response $response) use ($pm) {
40-
$response->end('Swoole');
30+
$server = new Swoole\Server('0.0.0.0', $pm->getFreePort(), SWOOLE_BASE);
31+
$server->set([
32+
'log_file' => '/dev/null',
33+
'open_eof_check' => true,
34+
'package_eof' => "\r\n\r\n",
35+
]);
36+
$server->on('Receive', function ($server, $fd, $reactor_id, $data) {
37+
echo $data;
38+
$server->close($fd);
4139
});
4240
$server->start();
4341
};
@@ -47,4 +45,8 @@ $pm->run();
4745

4846
?>
4947
--EXPECT--
50-
DONE
48+
GET http://127.0.0.1:1234/ HTTP/1.1
49+
Host: 127.0.0.1:1234
50+
Connection: keep-alive
51+
Accept-Encoding: gzip, deflate
52+

0 commit comments

Comments
 (0)