swoole_http_request->$server

Http请求相关的服务器信息,相当于PHP的$_SERVER数组。包含了Http请求的方法,URL路径,客户端IP等信息。

echo $request->server['request_time'];

request_time

request_time是在Worker设置的,在SWOOLE_PROCESS模式下存在dispatch过程,因此可能会与实际收包时间存在偏差。尤其是当请求量超过服务器处理能力时,request_time可能远滞后于实际收包时间。

可以通过$server->getClientInfo方法获取last_time获得准确的收包时间。