Skip to content

Commit 4473dee

Browse files
author
Martin Brecht-Precht
committedJul 14, 2016
Allow empty response bodies for HTTP status 204 responses.
1 parent f9ebbbf commit 4473dee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/Response/JsonResponse.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ class JsonResponse extends AbstractResponse
2020
*/
2121
protected function setBody($body)
2222
{
23+
if ($this->getStatusCode() === 204) {
24+
parent::setBody(null);
25+
return $this;
26+
}
2327
$body = @json_decode($body, true);
2428
if (is_null($body)) {
2529
throw new HttpResponseException('Response data is no valid JSON string.');
2630
}
27-
return parent::setBody($body);
31+
parent::setBody($body);
32+
return $this;
2833
}
2934

3035
}

0 commit comments

Comments
 (0)
Please sign in to comment.