Skip to content

Commit 07a84ab

Browse files
Return null on empty json string
PHP7 uses the JSOND extension for parsing JSON which now throws an error on an empty string. The JSON response is checked whether it is empty before decoding it and returns null for backwards compatibility.
1 parent ea17eff commit 07a84ab

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/OpenCloud/Common/Http/Message/Formatter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public static function decode(Response $response)
2828
{
2929
if (strpos($response->getHeader(Header::CONTENT_TYPE), Mime::JSON) !== false) {
3030
$string = (string) $response->getBody();
31+
if ('' === $string) {
32+
return null;
33+
}
3134
$response = json_decode($string);
3235
self::checkJsonError($string);
3336

0 commit comments

Comments
 (0)