Browse Source

fix binary body detection in response

main
yggverse 5 months ago
parent
commit
9368310e74
  1. 10
      src/Client/Response.php

10
src/Client/Response.php

@ -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…
Cancel
Save