From 338b85039606560e5c366755d091a4603b4ed828 Mon Sep 17 00:00:00 2001 From: Gene Surov Date: Fri, 1 Sep 2023 16:29:51 +0200 Subject: [PATCH] Body decode fix (#140) In case of empty body (e.g. `HTTP 204` for DELETE). This `decodeBody` regex fails and throws an error. The fix is to NOT decode an empty body. Co-authored-by: Eugene Surov --- src/ODataResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ODataResponse.php b/src/ODataResponse.php index 0e31d28..e973cd7 100644 --- a/src/ODataResponse.php +++ b/src/ODataResponse.php @@ -76,7 +76,7 @@ public function __construct($request, $body = null, $httpStatusCode = null, $hea $this->body = $body; $this->httpStatusCode = $httpStatusCode; $this->headers = $headers; - $this->decodedBody = $this->decodeBody(); + $this->decodedBody = $this->body ? $this->decodeBody() : []; } /**