diff --git a/src/Common/Classes/HttpRequest.php b/src/Common/Classes/HttpRequest.php index 24eefc8..ebd9ca4 100644 --- a/src/Common/Classes/HttpRequest.php +++ b/src/Common/Classes/HttpRequest.php @@ -116,6 +116,28 @@ protected function _hCurl($url, $data, $method, $header, $option) call_user_func_array([$client, $k], $v); } + if (!empty($option['addData'])) { + $cli = $client->getClient(); + foreach ($option['addData'] as $key => $value) { + if ($value instanceof \CURLFile) { + continue; + } + if (is_array($value)) { + foreach ($value as $v) { + if ($v instanceof \CURLFile) { + continue 2; + } + } + } + $cli->addData($key, $value); + } + } + + if ( ! empty($option['setData'])) { + $cli = $client->getClient(); + $cli->setData($option['setData']); + } + $calls = [ 'get' => function ($data) use ($client) { $client->setQuery($data); @@ -163,7 +185,7 @@ protected function _curl($url, $data, $method, $header, $option) case 'patch': case 'options': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method)); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); break; case 'head': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD');