add custom ws response headers

This commit is contained in:
Jerry 2023-02-10 13:16:04 +08:00
parent c86c6f493c
commit 3abd531980
2 changed files with 3 additions and 1 deletions

View File

@ -21,7 +21,7 @@
"jelix/version": "^2.0",
"koriym/attributes": "^1.0",
"nunomaduro/collision": "^6.3",
"onebot/libonebot": "^0.5",
"onebot/libonebot": "^0.5.7",
"php-di/php-di": "^7",
"psr/container": "^2.0",
"psr/simple-cache": "^3.0",

View File

@ -299,6 +299,8 @@ class OneBot12Adapter extends ZMPlugin
}
}
logger()->info('OneBot 12 反向 WS 连接鉴权成功,接入成功[' . $event->getFd() . ']');
// 接入 onebots 等实现需要回传 Sec-WebSocket-Protocol 头
$event->withResponse(HttpFactory::createResponse(101, headers: ['Sec-WebSocket-Protocol' => $event->getRequest()->getHeaderLine('Sec-WebSocket-Protocol')]));
}
// 设置 OneBot 相关的东西
ConnectionUtil::setConnection($event->getFd(), $info ?? []);