改名
This commit is contained in:
@@ -41,6 +41,9 @@ class Curl extends ClientAbstracts
|
|||||||
[$host, $isHttps, $path] = $this->matchHost($path);
|
[$host, $isHttps, $path] = $this->matchHost($path);
|
||||||
|
|
||||||
$host = $isHttps ? 'https://' . $host : 'http://' . $host;
|
$host = $isHttps ? 'https://' . $host : 'http://' . $host;
|
||||||
|
if ($this->getPort() != 443 && $this->getPort() != 80) {
|
||||||
|
$host .= ':' . $this->getPort();
|
||||||
|
}
|
||||||
|
|
||||||
$resource = $this->do(curl_init($host . $path), $host . $path, $method);
|
$resource = $this->do(curl_init($host . $path), $host . $path, $method);
|
||||||
if ($isHttps !== false) {
|
if ($isHttps !== false) {
|
||||||
@@ -49,8 +52,12 @@ class Curl extends ClientAbstracts
|
|||||||
if (empty($params)) {
|
if (empty($params)) {
|
||||||
return $resource;
|
return $resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($method === self::GET && !empty($this->getData())) {
|
||||||
|
curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getData());
|
||||||
|
}
|
||||||
if ($method === self::POST) {
|
if ($method === self::POST) {
|
||||||
curl_setopt($resource, CURLOPT_POSTFIELDS, HttpParse::parse($params));
|
curl_setopt($resource, CURLOPT_POSTFIELDS, $this->mergeParams($params));
|
||||||
}
|
}
|
||||||
if ($method === self::UPLOAD) {
|
if ($method === self::UPLOAD) {
|
||||||
curl_setopt($resource, CURLOPT_POSTFIELDS, $params);
|
curl_setopt($resource, CURLOPT_POSTFIELDS, $params);
|
||||||
@@ -91,6 +98,7 @@ class Curl extends ClientAbstracts
|
|||||||
*/
|
*/
|
||||||
private function do($resource, $path, $method)
|
private function do($resource, $path, $method)
|
||||||
{
|
{
|
||||||
|
var_dump($path);
|
||||||
curl_setopt($resource, CURLOPT_URL, $path);
|
curl_setopt($resource, CURLOPT_URL, $path);
|
||||||
curl_setopt($resource, CURLOPT_TIMEOUT, $this->getTimeout()); // 超时设置
|
curl_setopt($resource, CURLOPT_TIMEOUT, $this->getTimeout()); // 超时设置
|
||||||
curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, $this->getConnectTimeout()); // 超时设置
|
curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, $this->getConnectTimeout()); // 超时设置
|
||||||
|
|||||||
Reference in New Issue
Block a user