@@ -9,22 +9,23 @@ require __DIR__ . '/../include/bootstrap.php';
99use Swoole \Http \Server ;
1010use Swoole \Http \Response ;
1111
12- const SOCKET = __DIR__ . '/server.sock ' ;
12+ $ socket = tempnam (sys_get_temp_dir (), 'swoole-http-server- ' );
13+ unlink ($ socket );
1314
1415$ pm = new SwooleTest \ProcessManager ;
1516
16- $ pm ->parentFunc = function ($ pid ) use ($ pm ) {
17+ $ pm ->parentFunc = function ($ pid ) use ($ pm, $ socket ) {
1718 $ ch = curl_init ();
18- curl_setopt ($ ch , CURLOPT_UNIX_SOCKET_PATH , SOCKET );
19+ curl_setopt ($ ch , CURLOPT_UNIX_SOCKET_PATH , $ socket );
1920 curl_setopt ($ ch , CURLOPT_URL , "http://localhost/?a=hello&b=12345&test=world " );
2021 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
2122 $ output = curl_exec ($ ch );
2223 var_dump ($ output );
2324 $ pm ->kill ();
2425};
2526
26- $ pm ->childFunc = function () use ($ pm ) {
27- $ serv = new Server (SOCKET , 0 , SWOOLE_PROCESS , SWOOLE_SOCK_UNIX_STREAM );
27+ $ pm ->childFunc = function () use ($ pm, $ socket ) {
28+ $ serv = new Server ($ socket , 0 , SWOOLE_PROCESS , SWOOLE_SOCK_UNIX_STREAM );
2829 $ serv ->set ([
2930 'log_file ' => '/dev/null ' ,
3031 ]);
@@ -39,6 +40,7 @@ $pm->childFunc = function () use ($pm) {
3940
4041$ pm ->childFirst ();
4142$ pm ->run ();
43+ @unlink ($ socket );
4244?>
4345--EXPECT--
4446string(40) "{"a":"hello","b":"12345","test":"world"}"
0 commit comments