From d17fcf1fbed4121cfe412d9f2075ba30b9a192dc Mon Sep 17 00:00:00 2001 From: Valentin Date: Thu, 8 Dec 2022 16:46:00 +0100 Subject: [PATCH 1/3] feat: throw explicit curl error --- sources/RabbitMqHttpApiClient.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sources/RabbitMqHttpApiClient.php b/sources/RabbitMqHttpApiClient.php index fe9d374..54f4d2d 100644 --- a/sources/RabbitMqHttpApiClient.php +++ b/sources/RabbitMqHttpApiClient.php @@ -1562,6 +1562,10 @@ private function execCurl() $response = curl_exec($this->curl); $responseInfo = curl_getinfo($this->curl); if ($responseInfo['content_type'] !== 'application/json') { + if ($response === false) { + throw new RuntimeException(sprintf('Curl Error : "%s"', curl_error($this->curl))); + } + throw new RuntimeException($response); } @@ -1637,4 +1641,4 @@ protected function getObjectsVars($oneResult) return $oneResult; } -} \ No newline at end of file +} From 7ec6486e8ce0aa7b8e538c91770bdeb3977131a5 Mon Sep 17 00:00:00 2001 From: Valentin Date: Thu, 8 Dec 2022 16:47:06 +0100 Subject: [PATCH 2/3] fix: getMessages() --- sources/RabbitMqHttpApiClient.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sources/RabbitMqHttpApiClient.php b/sources/RabbitMqHttpApiClient.php index 54f4d2d..5774402 100644 --- a/sources/RabbitMqHttpApiClient.php +++ b/sources/RabbitMqHttpApiClient.php @@ -1528,7 +1528,9 @@ private function requestPost($path, array $requestVars = []) { curl_setopt($this->curl, CURLOPT_URL, $this->getServiceUrl($path)); curl_setopt($this->curl, CURLOPT_POST, true); - curl_setopt($this->curl, CURLOPT_POSTFIELDS, $this->buildPostBody($requestVars)); + if($requestVars) { + curl_setopt($this->curl, CURLOPT_POSTFIELDS, $this->buildPostBody($requestVars)); + } return $this->execCurl(); } From d4d34712b47b84f54419c3f41d63f6fbbf71b4b5 Mon Sep 17 00:00:00 2001 From: Valentin Date: Fri, 9 Dec 2022 14:52:39 +0000 Subject: [PATCH 3/3] fix: purgeQueue() --- sources/RabbitMqHttpApiClient.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sources/RabbitMqHttpApiClient.php b/sources/RabbitMqHttpApiClient.php index 5774402..413b29f 100644 --- a/sources/RabbitMqHttpApiClient.php +++ b/sources/RabbitMqHttpApiClient.php @@ -1562,6 +1562,11 @@ private function requestGet($path, array $requestVars = []) private function execCurl() { $response = curl_exec($this->curl); + + if($response === '') { + return []; + } + $responseInfo = curl_getinfo($this->curl); if ($responseInfo['content_type'] !== 'application/json') { if ($response === false) {