Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions sources/RabbitMqHttpApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -1560,8 +1562,17 @@ 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) {
throw new RuntimeException(sprintf('Curl Error : "%s"', curl_error($this->curl)));
}

throw new RuntimeException($response);
}

Expand Down Expand Up @@ -1637,4 +1648,4 @@ protected function getObjectsVars($oneResult)

return $oneResult;
}
}
}