3
This commit is contained in:
+17
-16
@@ -648,30 +648,18 @@ class HttpClient
|
||||
private function curlParse($url, $data)
|
||||
{
|
||||
$ch = curl_init();
|
||||
|
||||
var_dump($this->createRequestUrl($url, $data));
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $this->createRequestUrl($url, $data));
|
||||
if ($this->timeout > 0) {
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); // 超时设置
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); // 超时设置
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->parseHeaderMat());
|
||||
|
||||
var_dump($this->parseHeaderMat());
|
||||
|
||||
if ($headers = $this->parseHeaderMat()) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
$this->setSslFile($ch);
|
||||
if (!empty($this->agent)) {
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $this->agent);
|
||||
}
|
||||
if (file_exists($cert = $this->getSslCertFile())) {
|
||||
curl_setopt($ch, CURLOPT_SSLCERT, $cert);
|
||||
}
|
||||
if (file_exists($key = $this->getSslKeyFile())) {
|
||||
curl_setopt($ch, CURLOPT_SSLKEY, $key);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//返回内容
|
||||
@@ -681,7 +669,6 @@ class HttpClient
|
||||
if ($this->method == self::POST) {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
}
|
||||
|
||||
if ($this->method != self::GET) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
@@ -696,6 +683,20 @@ class HttpClient
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param resource $ch
|
||||
*/
|
||||
private function setSslFile($ch)
|
||||
{
|
||||
if (file_exists($cert = $this->getSslCertFile())) {
|
||||
curl_setopt($ch, CURLOPT_SSLCERT, $cert);
|
||||
}
|
||||
if (file_exists($key = $this->getSslKeyFile())) {
|
||||
curl_setopt($ch, CURLOPT_SSLKEY, $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $url
|
||||
* @param $params
|
||||
@@ -986,7 +987,7 @@ class HttpClient
|
||||
}
|
||||
$headers = [];
|
||||
foreach ($this->header as $key => $val) {
|
||||
$header = $key . ':' . $val;
|
||||
$header = $key . ': ' . $val;
|
||||
if (in_array($header, $headers)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user