Skip to content

Commit

Permalink
Fix return value on write context
Browse files Browse the repository at this point in the history
  • Loading branch information
rumeau committed Jul 7, 2016
1 parent 8e54345 commit ce4c0b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Message/AbstractRestRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ function ($event) {
$httpRequest->getCurlOptions()->set(CURLOPT_SSLVERSION, 6); // CURL_SSLVERSION_TLSv1_2 for libcurl < 7.35
$httpResponse = $httpRequest->send();
// Empty response body should be parsed also as and empty array
$jsonToArrayResponse = !empty($httpResponse->getBody(true)) ? $httpResponse->json() : array();
$body = $httpResponse->getBody(true);
$jsonToArrayResponse = !empty($body) ? $httpResponse->json() : array();
return $this->response = $this->createResponse($jsonToArrayResponse, $httpResponse->getStatusCode());
} catch (\Exception $e) {
throw new InvalidResponseException(
Expand Down
3 changes: 2 additions & 1 deletion src/Message/RestTokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function ($event) {

$httpResponse = $httpRequest->setAuth($this->getClientId(), $this->getSecret())->send();
// Empty response body should be parsed also as and empty array
$jsonToArrayResponse = !empty($httpResponse->getBody(true)) ? $httpResponse->json() : array();
$body = $httpResponse->getBody(true);
$jsonToArrayResponse = !empty($body) ? $httpResponse->json() : array();
return $this->response = new RestResponse($this, $jsonToArrayResponse, $httpResponse->getStatusCode());
}
}

0 comments on commit ce4c0b2

Please sign in to comment.