This commit is contained in:
2020-11-17 18:46:41 +08:00
parent 7a6ca96ac3
commit d7f3d4d65f
2 changed files with 104 additions and 106 deletions
+5 -6
View File
@@ -46,7 +46,6 @@ class Client extends ClientAbstracts
private function coroutine($url, $data = [])
{
try {
var_dump($url);
$client = $this->generate_client($data, ...$url);
if ($client->statusCode < 0) {
throw new Exception($client->errMsg);
@@ -79,13 +78,15 @@ class Client extends ClientAbstracts
*/
private function generate_client($data, $host, $isHttps, $path)
{
$port = $isHttps ? 443 : $this->getPort();
$client = new SClient($host, $port, $this->isSSL());
if ($isHttps || $this->isSSL()) {
$client = new SClient($host, 443, $this->isSSL());
} else {
$client = new SClient($host, $this->getPort(), $this->isSSL());
}
if (strpos($path, '/') !== 0) {
$path = '/' . $path;
}
$client->set($this->settings());
if (!empty($this->getAgent())) {
$this->addHeader('User-Agent', $this->getAgent());
@@ -93,7 +94,6 @@ class Client extends ClientAbstracts
$client->setHeaders($this->getHeader());
$client->setMethod(strtoupper($this->getMethod()));
if (strtolower($this->getMethod()) == self::GET && !empty($data)) {
$path .= '?' . $data;
} else {
@@ -103,7 +103,6 @@ class Client extends ClientAbstracts
if (!empty($this->getData())) {
$client->setData($this->getData());
}
$client->execute($path);
$client->close();
return $client;
-1
View File
@@ -747,7 +747,6 @@ abstract class ClientAbstracts extends Component implements IClient
private function defaultString($string)
{
$host = $this->getHost();
$host .= ':' . $this->getPort();
if ($string == '/') {
$string = '';
} else if (strpos($string, '/') !== 0) {