This commit is contained in:
2020-11-18 14:15:25 +08:00
parent d5bd5bd269
commit e945e33601
2 changed files with 184 additions and 182 deletions
+1
View File
@@ -19,6 +19,7 @@ abstract class ClientAbstracts extends Component implements IClient
{
const POST = 'post';
const UPLOAD = 'upload';
const GET = 'get';
const DELETE = 'delete';
const OPTIONS = 'options';
+3 -2
View File
@@ -43,6 +43,8 @@ class Curl extends ClientAbstracts
$resource = $this->do(curl_init($host . $path), $host . $path, $method);
if ($method === self::POST && !empty($params)) {
curl_setopt($resource, CURLOPT_POSTFIELDS, HttpParse::parse($params));
} else if ($method === self::UPLOAD) {
curl_setopt($resource, CURLOPT_POSTFIELDS, $params);
}
if ($isHttps !== false) {
@@ -124,8 +126,7 @@ class Curl extends ClientAbstracts
curl_setopt($resource, CURLOPT_RETURNTRANSFER, TRUE);//返回内容
curl_setopt($resource, CURLOPT_FOLLOWLOCATION, TRUE);// 跟踪重定向
curl_setopt($resource, CURLOPT_ENCODING, 'gzip,deflate');
if ($method === self::POST) {
if ($method === self::POST || $method == self::UPLOAD) {
curl_setopt($resource, CURLOPT_POST, 1);
}