diff --git a/HttpServer/Client/Client.php b/HttpServer/Client/Client.php index 0ae1ff2f..10a740ab 100644 --- a/HttpServer/Client/Client.php +++ b/HttpServer/Client/Client.php @@ -71,6 +71,7 @@ class Client extends ClientAbstracts } } + /** * @param $data * @param $host @@ -85,29 +86,41 @@ class Client extends ClientAbstracts } else { $client = new SClient($host, $this->getPort(), false); } - if (strpos($path, '/') !== 0) { - $path = '/' . $path; - } $client->set($this->settings()); if (!empty($this->getAgent())) { $this->addHeader('User-Agent', $this->getAgent()); } $client->setHeaders($this->getHeader()); $client->setMethod(strtoupper($this->getMethod())); - if ($this->isGet() && !empty($data)) { - $path .= '?' . $data; - } else { - $this->setData($this->mergeParams($data)); - } - - if (!empty($this->getData())) { - $client->setData($this->getData()); - } - $client->execute($path); + $client->execute($this->setParams($client, $path, $data)); $client->close(); return $client; } + + /** + * @param $client + * @param $path + * @param $data + * @return string + */ + private function setParams(SClient $client, $path, $data): string + { + if ($this->isGet()) { + if (!empty($data)) $path .= '?' . $data; + if (!empty($this->getData())) { + $client->setData($this->getData()); + } + } else { + if (!empty($this->getData())) { + $client->setData($this->getData()); + } else { + $client->setData($this->mergeParams($data)); + } + } + return $path; + } + /** * @return array */ diff --git a/HttpServer/Client/ClientAbstracts.php b/HttpServer/Client/ClientAbstracts.php index d4d9f434..fc6c5701 100644 --- a/HttpServer/Client/ClientAbstracts.php +++ b/HttpServer/Client/ClientAbstracts.php @@ -676,6 +676,15 @@ abstract class ClientAbstracts extends Component implements IClient return strtolower($this->method) === self::POST; } + /** + * @return bool + * check isPost Request + */ + #[Pure] public function isUpload(): bool + { + return strtolower($this->method) === self::UPLOAD; + } + /** * @return bool diff --git a/System/Event.php b/System/Event.php index 8504fa10..869b80e5 100644 --- a/System/Event.php +++ b/System/Event.php @@ -21,9 +21,6 @@ class Event extends BaseObject private static array $_events = []; - const EVENT_ERROR = 'WORKER:ERROR'; - const EVENT_STOP = 'WORKER:STOP'; - const EVENT_EXIT = 'WORKER:EXIT'; const PIPE_MESSAGE = 'SERVER:PIPE:MESSAGE'; const TASK_FINISH = 'SERVER:TASK::FINISH';