diff --git a/HttpServer/Client/Client.php b/HttpServer/Client/Client.php index f704a6a6..62a42916 100644 --- a/HttpServer/Client/Client.php +++ b/HttpServer/Client/Client.php @@ -48,10 +48,10 @@ class Client extends ClientAbstracts { try { $client = $this->generate_client($data, ...$url); + $this->setData(''); if ($client->statusCode < 0) { throw new Exception($client->errMsg); } - $this->setData(''); $body = $this->resolve($client->getHeaders(), $client->body); if (in_array($client->getStatusCode(), [200, 201])) { return $this->structure($body, $data, $client->getHeaders()); diff --git a/HttpServer/Client/ClientAbstracts.php b/HttpServer/Client/ClientAbstracts.php index c714ff36..16bb21c9 100644 --- a/HttpServer/Client/ClientAbstracts.php +++ b/HttpServer/Client/ClientAbstracts.php @@ -62,6 +62,12 @@ abstract class ClientAbstracts extends Component implements IClient } + protected function cleanData(): void + { + $this->_data = ''; + } + + /** * @param $path * @param array $params diff --git a/HttpServer/Client/Curl.php b/HttpServer/Client/Curl.php index c47d1f0c..cfd7ac8a 100644 --- a/HttpServer/Client/Curl.php +++ b/HttpServer/Client/Curl.php @@ -135,6 +135,9 @@ class Curl extends ClientAbstracts */ private function execute($curl): Result|bool|array|string { + defer(function () { + $this->cleanData(); + }); $output = curl_exec($curl); if ($output === false) { return $this->fail(400, curl_error($curl));