增加 SSE 兼容性
This commit is contained in:
parent
717e681fcf
commit
35aeecd2c7
@ -18,7 +18,11 @@ class AddHeaders
|
|||||||
public function handle(Request $request, Closure $next): mixed
|
public function handle(Request $request, Closure $next): mixed
|
||||||
{
|
{
|
||||||
$response = $next($request);
|
$response = $next($request);
|
||||||
$response->header('Node-Id', ClusterSupport::currentNode()['id']);
|
|
||||||
|
// SSE, 检测有没有 header() 方法。
|
||||||
|
if (method_exists($response, 'header')) {
|
||||||
|
$response->header('Node-Id', ClusterSupport::currentNode()['id']);
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,16 @@ public function handle(Request $request, Closure $next): mixed
|
|||||||
|
|
||||||
$end = microtime(true);
|
$end = microtime(true);
|
||||||
|
|
||||||
|
$status = 0;
|
||||||
|
// 检测有没有 status() 方法。
|
||||||
|
if (method_exists($response, 'status')) {
|
||||||
|
$status = $response->status();
|
||||||
|
}
|
||||||
|
|
||||||
ClusterSupport::publish('http.outgoing', [
|
ClusterSupport::publish('http.outgoing', [
|
||||||
'id' => $random_id,
|
'id' => $random_id,
|
||||||
'method' => $method,
|
'method' => $method,
|
||||||
'status' => $response->status(),
|
'status' => $status,
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
// 'headers' => $response->headers->all(),
|
// 'headers' => $response->headers->all(),
|
||||||
// 'content' => $response->getContent(),
|
// 'content' => $response->getContent(),
|
||||||
|
Loading…
Reference in New Issue
Block a user