Skip to content

Commit c408340

Browse files
authored
Merge pull request #83 from os-cillation/master
Only parse content if the response code is not 204
2 parents 597f826 + 17bf62c commit c408340

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Types/Result.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ class Result {
5252
* @SuppressWarnings("PHPMD.StaticAccess")
5353
*/
5454
public function __construct($query, $requestMethod, Response $response, array $options = []) {
55-
$tokens = (new PHPSQLParser())->parse($query);
56-
$content = Format::create($options)->decode($response->getContent());
55+
$tokens = (new PHPSQLParser())->parse($query);
56+
5757
$responseCode = $response->getStatusCode();
5858

59+
$content = $responseCode === Response::HTTP_NO_CONTENT ? [] : Format::create($options)->decode($response->getContent());
60+
5961
$this->result = $this->createResult($tokens, $requestMethod, $responseCode, $content);
6062
$this->id = $this->createId($tokens);
6163
}
@@ -106,4 +108,4 @@ private function createResult(array $tokens, $requestMethod, $responseCode, arra
106108

107109
return $result;
108110
}
109-
}
111+
}

0 commit comments

Comments
 (0)