fix binary body detection in response

This commit is contained in:
yggverse 2024-06-24 23:27:15 +03:00
parent 0d5db685d1
commit 9368310e74

View File

@ -17,7 +17,7 @@ class Response
$match = [];
preg_match(
'/(?<code>\d{2})\s(?<meta>.*)\r\n(?<body>.*)/su',
'/^(?<code>\d{2})(?<meta>.*)$/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
);
}
}