改名
This commit is contained in:
@@ -43,41 +43,21 @@ class Curl extends ClientAbstracts
|
||||
$host = $isHttps ? 'https://' . $host : 'http://' . $host;
|
||||
|
||||
$resource = $this->do(curl_init($host . $path), $host . $path, $method);
|
||||
if ($method === self::POST && !empty($params)) {
|
||||
if ($isHttps !== false) {
|
||||
$this->curlHandlerSslSet($resource);
|
||||
}
|
||||
if (empty($params)) {
|
||||
return $resource;
|
||||
}
|
||||
var_dump($params);
|
||||
if ($method === self::POST) {
|
||||
curl_setopt($resource, CURLOPT_POSTFIELDS, HttpParse::parse($params));
|
||||
} else if ($method === self::UPLOAD) {
|
||||
curl_setopt($resource, CURLOPT_POSTFIELDS, $params);
|
||||
}
|
||||
|
||||
if ($isHttps !== false) {
|
||||
return $this->curlHandlerSslSet($resource);
|
||||
}
|
||||
return $resource;
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * @param $path
|
||||
// * @param $params
|
||||
// * @return mixed|resource
|
||||
// * @throws Exception
|
||||
// */
|
||||
// public function upload($path, $params = [])
|
||||
// {
|
||||
// [$host, $isHttps, $path] = $this->matchHost($path);
|
||||
//
|
||||
// $host = $isHttps ? 'https://' . $host : 'http://' . $host;
|
||||
//
|
||||
// $resource = $this->do(curl_init($host . $path), $host . $path, self::POST);
|
||||
//
|
||||
// curl_setopt($resource, CURLOPT_POSTFIELDS, $params);
|
||||
//
|
||||
// if ($isHttps !== false) {
|
||||
// return $this->execute($this->curlHandlerSslSet($resource));
|
||||
// }
|
||||
// return $this->execute($resource);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @param $resource
|
||||
@@ -111,6 +91,7 @@ class Curl extends ClientAbstracts
|
||||
*/
|
||||
private function do($resource, $path, $method)
|
||||
{
|
||||
curl_setopt($resource, CURLOPT_URL, $path);
|
||||
curl_setopt($resource, CURLOPT_TIMEOUT, $this->getTimeout()); // 超时设置
|
||||
curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, $this->getConnectTimeout()); // 超时设置
|
||||
|
||||
@@ -133,9 +114,6 @@ class Curl extends ClientAbstracts
|
||||
if ($method === self::POST || $method == self::UPLOAD) {
|
||||
curl_setopt($resource, CURLOPT_POST, 1);
|
||||
}
|
||||
|
||||
var_dump($path);
|
||||
curl_setopt($resource, CURLOPT_URL, $path);
|
||||
curl_setopt($resource, CURLOPT_CUSTOMREQUEST, $method);
|
||||
|
||||
return $resource;
|
||||
@@ -150,7 +128,6 @@ class Curl extends ClientAbstracts
|
||||
private function execute($curl)
|
||||
{
|
||||
$output = curl_exec($curl);
|
||||
var_dump($output);
|
||||
if ($output === false) {
|
||||
return $this->fail(400, curl_error($curl));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user