增加 SSE 兼容性
This commit is contained in:
parent
717e681fcf
commit
35aeecd2c7
@ -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;
|
||||
}
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user