Skip to content

Commit 38c24c9

Browse files
committed
add post parse, update to 0.6.6
1 parent 05ab0da commit 38c24c9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/OneBot/Driver/Swoole/TopEventListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function onRequest(array $config, Request $request, Response $response)
9696
$req = $req->withQueryParams($request->get ?? [])
9797
->withCookieParams($request->cookie ?? []);
9898
$uploaded = [];
99+
// 上传的文件
99100
if (!empty($request->files)) {
100101
foreach ($request->files as $key => $value) {
101102
$upload = new UploadedFile([
@@ -108,6 +109,10 @@ public function onRequest(array $config, Request $request, Response $response)
108109
$req = $req->withUploadedFiles($uploaded);
109110
}
110111
}
112+
// post 包体
113+
if (!empty($request->post)) {
114+
$req = $req->withParsedBody($request->post);
115+
}
111116
$event = new HttpRequestEvent($req);
112117
try {
113118
$event->setSocketConfig($config);

src/OneBot/Driver/Workerman/TopEventListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public function onHttpRequest(array $config, TcpConnection $connection, Request
166166
);
167167
$req = $req->withQueryParams($request->get() ?? [])
168168
->withCookieParams($request->cookie() ?? []);
169+
// 解析文件
169170
if (!empty($request->file())) {
170171
$uploaded = [];
171172
foreach ($request->file() as $key => $value) {
@@ -179,6 +180,10 @@ public function onHttpRequest(array $config, TcpConnection $connection, Request
179180
$req = $req->withUploadedFiles($uploaded);
180181
}
181182
}
183+
// 解析 post
184+
if (!empty($request->post())) {
185+
$req = $req->withParsedBody($request->post());
186+
}
182187
$event = new HttpRequestEvent($req);
183188
$event->setSocketConfig($config);
184189
$send_callable = function (ResponseInterface $psr_response) use ($connection) {

src/OneBot/global_defines.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use ZM\Logger\ConsoleLogger;
1414

1515
const ONEBOT_VERSION = '12';
16-
const ONEBOT_LIBOB_VERSION = '0.6.5';
16+
const ONEBOT_LIBOB_VERSION = '0.6.6';
1717

1818
const ONEBOT_JSON = 1;
1919
const ONEBOT_MSGPACK = 2;

0 commit comments

Comments
 (0)