mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
fix: 修复无法读取未携带Content-Type的请求头的节点后端上报的数据的问题
This commit is contained in:
parent
c2b08c2627
commit
93200ac057
@ -9,6 +9,7 @@ use App\Utils\CacheKey;
|
|||||||
use App\Utils\Helper;
|
use App\Utils\Helper;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class UniProxyController extends Controller
|
class UniProxyController extends Controller
|
||||||
{
|
{
|
||||||
@ -33,10 +34,11 @@ class UniProxyController extends Controller
|
|||||||
// 后端提交数据
|
// 后端提交数据
|
||||||
public function push(Request $request)
|
public function push(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request->validate([
|
$res = json_decode(get_request_content(), true);
|
||||||
"*.0" => 'integer',
|
$data = Validator::make($res, [
|
||||||
"*.1" => 'integer'
|
'*.0' => 'integer',
|
||||||
]);
|
'*.1' => 'integer',
|
||||||
|
])->validate();
|
||||||
|
|
||||||
$nodeType = $request->input('node_type');
|
$nodeType = $request->input('node_type');
|
||||||
$nodeId = $request->input('node_id');
|
$nodeId = $request->input('node_id');
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.1",
|
||||||
"cedar2025/http-foundation": "6.4.x-dev",
|
"cedar2025/http-foundation": "6.4.x-dev",
|
||||||
|
"cweagans/composer-patches": "^1.7",
|
||||||
"doctrine/dbal": "^3.7",
|
"doctrine/dbal": "^3.7",
|
||||||
"firebase/php-jwt": "^6.3",
|
"firebase/php-jwt": "^6.3",
|
||||||
"google/cloud-storage": "^1.35",
|
"google/cloud-storage": "^1.35",
|
||||||
@ -45,11 +46,19 @@
|
|||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true
|
"sort-packages": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"cweagans/composer-patches": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"dont-discover": []
|
"dont-discover": []
|
||||||
|
},
|
||||||
|
"patches": {
|
||||||
|
"joanhey/adapterman": {
|
||||||
|
"http": "patches/Http.patch"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
23
patches/Http.patch
Normal file
23
patches/Http.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
diff --git a/src/Http.php b/src/Http.php
|
||||||
|
index 6c6cb16..f1a7f3f 100644
|
||||||
|
--- a/src/Http.php
|
||||||
|
+++ b/src/Http.php
|
||||||
|
@@ -680,7 +680,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse $_POST.
|
||||||
|
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['CONTENT_TYPE']) {
|
||||||
|
+ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
switch ($_SERVER['CONTENT_TYPE']) {
|
||||||
|
case 'multipart/form-data':
|
||||||
|
static::parseUploadFiles($http_body, $http_post_boundary);
|
||||||
|
@@ -691,6 +691,8 @@
|
||||||
|
case 'application/x-www-form-urlencoded':
|
||||||
|
\parse_str($http_body, $_POST);
|
||||||
|
break;
|
||||||
|
+ default:
|
||||||
|
+ $_POST = \json_decode($http_body, true) ?? [];
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
+ }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user