Swoole HTTP服务端测试
作者:互联网
1.创建服务端server.php
<?php $http = new Swoole\Http\Server('0.0.0.0', 9502); $http->on('Request', function ($request, $response) { $response->header('Content-Type', 'text/html; charset=utf-8'); //向客户端发送HTML内容 $response->end('<h1>Hello Swoole. #' . rand(1000, 9999) . '</h1>'); }); $http->start();
2.通过CURL访问端口
curl http://127.0.0.1:9502
返回数据:<h1>Hello Swoole. #5463</h1>
标签:rand,http,Swoole,response,HTTP,Hello,服务端 来源: https://www.cnblogs.com/shineen/p/16410515.html