add clear

This commit is contained in:
2020-04-03 17:22:44 +08:00
parent 08878a7090
commit 339532536f
+19 -7
View File
@@ -460,13 +460,7 @@ class HttpClient
private function generate_client($host, $url, $data)
{
$client = new SClient($host, $this->getHostPort(), $this->isSSL);
$client->set([
'ssl_host_name' => $this->host,
'ssl_cert_file' => $this->getSslCertFile(),
'ssl_key_file' => $this->getSslKeyFile(),
'ssl_verify_peer' => true,
'ssl_cafile' => $this->getCa(),
]);
$client->set($this->settings());
if (!empty($this->agent)) {
$this->header['User-Agent'] = $this->agent;
}
@@ -506,6 +500,24 @@ class HttpClient
return $client;
}
private function settings()
{
$sslCert = $this->getSslCertFile();
$sslKey = $this->getSslKeyFile();
$sslCa = $this->getCa();
if (empty($sslCert) || empty($sslKey) || empty($sslCa)) {
return [];
}
$params['ssl_host_name'] = $this->host;
$params['ssl_cert_file'] = $this->getSslCertFile();
$params['ssl_key_file'] = $this->getSslKeyFile();
$params['ssl_verify_peer'] = true;
$params['ssl_cafile'] = $sslCa;
return $params;
}
/**
* @param $url
* @param array $data