增加 SSE 兼容性

This commit is contained in:
iVampireSP.com 2023-02-10 03:04:13 +08:00
parent 717e681fcf
commit 35aeecd2c7
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 12 additions and 2 deletions

View File

@ -18,7 +18,11 @@ class AddHeaders
public function handle(Request $request, Closure $next): mixed
{
$response = $next($request);
// SSE, 检测有没有 header() 方法。
if (method_exists($response, 'header')) {
$response->header('Node-Id', ClusterSupport::currentNode()['id']);
}
return $response;
}

View File

@ -43,10 +43,16 @@ public function handle(Request $request, Closure $next): mixed
$end = microtime(true);
$status = 0;
// 检测有没有 status() 方法。
if (method_exists($response, 'status')) {
$status = $response->status();
}
ClusterSupport::publish('http.outgoing', [
'id' => $random_id,
'method' => $method,
'status' => $response->status(),
'status' => $status,
'path' => $path,
// 'headers' => $response->headers->all(),
// 'content' => $response->getContent(),