mirror of
https://github.com/YGGverse/gemini-php.git
synced 2026-03-31 17:05:29 +00:00
fix binary body detection in response
This commit is contained in:
parent
0d5db685d1
commit
9368310e74
1 changed files with 6 additions and 4 deletions
|
|
@ -17,7 +17,7 @@ class Response
|
||||||
$match = [];
|
$match = [];
|
||||||
|
|
||||||
preg_match(
|
preg_match(
|
||||||
'/(?<code>\d{2})\s(?<meta>.*)\r\n(?<body>.*)/su',
|
'/^(?<code>\d{2})(?<meta>.*)$/m',
|
||||||
$data,
|
$data,
|
||||||
$match
|
$match
|
||||||
);
|
);
|
||||||
|
|
@ -37,14 +37,16 @@ class Response
|
||||||
if (isset($match['meta']) && mb_strlen($match['meta']) <= 1024)
|
if (isset($match['meta']) && mb_strlen($match['meta']) <= 1024)
|
||||||
{
|
{
|
||||||
$this->setMeta(
|
$this->setMeta(
|
||||||
(string) $match['meta']
|
trim(
|
||||||
|
(string) $match['meta']
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($match['body']))
|
if ($body = substr($data, strpos($data, chr(10)) + 1))
|
||||||
{
|
{
|
||||||
$this->setBody(
|
$this->setBody(
|
||||||
(string) (string) $match['body']
|
(string) $body
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue