Skip to content

Commit

Permalink
fix null response bug
Browse files Browse the repository at this point in the history
fix bug when response is null (camunda is down)
  • Loading branch information
HunterXuan committed Jul 11, 2018
1 parent 1d2d531 commit 224f943
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Service/BasicService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Camunda\Helper\FileCollection;
use Camunda\Helper\VariableCollection;
use Camunda\Entity\Request\BasicRequest;
use GuzzleHttp\Psr7\Response;

/**
* Class BasicService
Expand Down Expand Up @@ -241,11 +242,16 @@ public function run($HAL = false)
$response = $requestException->getResponse();
}

$this->responseCode = $response->getStatusCode();
$this->responseContents = $response->getBody()->getContents();
if ($response instanceof Response) {
$this->responseCode = $response->getStatusCode();
$this->responseContents = $response->getBody()->getContents();

if (in_array('application/json', $response->getHeader('Content-Type')) || in_array('application/hal+json', $response->getHeader('Content-Type'))) {
$this->responseContents = json_decode($this->responseContents, false);
if (in_array('application/json', $response->getHeader('Content-Type')) || in_array('application/hal+json', $response->getHeader('Content-Type'))) {
$this->responseContents = json_decode($this->responseContents, false);
}
} else {
$this->responseCode = '';
$this->responseContents = '';
}

return $this;
Expand Down

0 comments on commit 224f943

Please sign in to comment.