Revert "改名"
This reverts commit fdf58326
This commit is contained in:
+36
-15
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
namespace Kiri;
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Kiri\Abstracts\Logger;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Message\Stream;
|
||||
@@ -107,22 +108,10 @@ class AsyncClient extends ClientAbstracts
|
||||
*/
|
||||
private function execute(string $path, string $content)
|
||||
{
|
||||
$array = [];
|
||||
$array[] = strtoupper($this->getMethod()) . ' ' . $path . ' HTTP/1.1';
|
||||
if (!empty($this->getHeader())) {
|
||||
foreach ($this->getHeader() as $key => $value) {
|
||||
$array[] = sprintf('%s: %s', $key, $value);
|
||||
}
|
||||
}
|
||||
$array = $this->_parseHeaders($path);
|
||||
|
||||
$this->client->send(implode("\r\n", $array) . "\r\n\r\n" . $content);
|
||||
$receive = '';
|
||||
while (true) {
|
||||
$_tmp = $this->client->recv();
|
||||
if (empty($_tmp)) {
|
||||
break;
|
||||
}
|
||||
$receive .= $_tmp;
|
||||
}
|
||||
$receive = $this->waite('');
|
||||
|
||||
Kiri::getDi()->get(Logger::class)->debug($receive);
|
||||
|
||||
@@ -137,6 +126,38 @@ class AsyncClient extends ClientAbstracts
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return array
|
||||
*/
|
||||
#[Pure] private function _parseHeaders(string $path): array
|
||||
{
|
||||
$array = [];
|
||||
$array[] = strtoupper($this->getMethod()) . ' ' . $path . ' HTTP/1.1';
|
||||
if (!empty($this->getHeader())) {
|
||||
foreach ($this->getHeader() as $key => $value) {
|
||||
$array[] = sprintf('%s: %s', $key, $value);
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* @return mixed
|
||||
*/
|
||||
private function waite($string): mixed
|
||||
{
|
||||
$tmp = $this->client->recv();
|
||||
if (empty($tmp)) {
|
||||
return $string;
|
||||
}
|
||||
$string .= $tmp;
|
||||
return $this->waite($string);
|
||||
}
|
||||
|
||||
|
||||
private function chunked()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user