From 9368310e74003d922449d13bdc4256432337ce55 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 24 Jun 2024 23:27:15 +0300 Subject: [PATCH] fix binary body detection in response --- src/Client/Response.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Client/Response.php b/src/Client/Response.php index 5988423..aabc7cf 100644 --- a/src/Client/Response.php +++ b/src/Client/Response.php @@ -17,7 +17,7 @@ class Response $match = []; preg_match( - '/(?\d{2})\s(?.*)\r\n(?.*)/su', + '/^(?\d{2})(?.*)$/m', $data, $match ); @@ -37,14 +37,16 @@ class Response if (isset($match['meta']) && mb_strlen($match['meta']) <= 1024) { $this->setMeta( - (string) $match['meta'] + trim( + (string) $match['meta'] + ) ); } - if (isset($match['body'])) + if ($body = substr($data, strpos($data, chr(10)) + 1)) { $this->setBody( - (string) (string) $match['body'] + (string) $body ); } }