Skip to content

Commit

Permalink
add post parse, update to 0.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywhalecc committed Jul 28, 2023
1 parent 05ab0da commit 38c24c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/OneBot/Driver/Swoole/TopEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function onRequest(array $config, Request $request, Response $response)
$req = $req->withQueryParams($request->get ?? [])
->withCookieParams($request->cookie ?? []);
$uploaded = [];
// 上传的文件
if (!empty($request->files)) {
foreach ($request->files as $key => $value) {
$upload = new UploadedFile([
Expand All @@ -108,6 +109,10 @@ public function onRequest(array $config, Request $request, Response $response)
$req = $req->withUploadedFiles($uploaded);
}
}
// post 包体
if (!empty($request->post)) {
$req = $req->withParsedBody($request->post);
}
$event = new HttpRequestEvent($req);
try {
$event->setSocketConfig($config);
Expand Down
5 changes: 5 additions & 0 deletions src/OneBot/Driver/Workerman/TopEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public function onHttpRequest(array $config, TcpConnection $connection, Request
);
$req = $req->withQueryParams($request->get() ?? [])
->withCookieParams($request->cookie() ?? []);
// 解析文件
if (!empty($request->file())) {
$uploaded = [];
foreach ($request->file() as $key => $value) {
Expand All @@ -179,6 +180,10 @@ public function onHttpRequest(array $config, TcpConnection $connection, Request
$req = $req->withUploadedFiles($uploaded);
}
}
// 解析 post
if (!empty($request->post())) {
$req = $req->withParsedBody($request->post());
}
$event = new HttpRequestEvent($req);
$event->setSocketConfig($config);
$send_callable = function (ResponseInterface $psr_response) use ($connection) {
Expand Down
2 changes: 1 addition & 1 deletion src/OneBot/global_defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use ZM\Logger\ConsoleLogger;

const ONEBOT_VERSION = '12';
const ONEBOT_LIBOB_VERSION = '0.6.5';
const ONEBOT_LIBOB_VERSION = '0.6.6';

const ONEBOT_JSON = 1;
const ONEBOT_MSGPACK = 2;
Expand Down

0 comments on commit 38c24c9

Please sign in to comment.