mirror of
https://github.com/YGGverse/gemini-php.git
synced 2025-03-13 06:01:58 +00:00
fix binary body detection in response
This commit is contained in:
parent
0d5db685d1
commit
9368310e74
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user