mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-18 05:04:51 +08:00
Merge pull request #249 from zhamao-robot/fix-zmrequest-array-bug
优化 ZMRequest POST 数据时允许直接传入数组
This commit is contained in:
commit
06964a97f0
@ -57,6 +57,10 @@ class ZMRequest
|
||||
'url' => ($url instanceof UriInterface ? $url->__toString() : $url),
|
||||
], $config));
|
||||
$socket->withoutAsync();
|
||||
if (is_array($data)) {
|
||||
$data = http_build_query($data);
|
||||
$header['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
$obj = $socket->post($data, $header, fn (ResponseInterface $response) => $response, fn () => false);
|
||||
if ($obj instanceof ResponseInterface) {
|
||||
if ($obj->getStatusCode() !== 200 && $only_body) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user