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