From 883a78354a16376ec3bc63efcb92ba79b58b7959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 31 Mar 2021 11:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Client/Http2.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/HttpServer/Client/Http2.php b/HttpServer/Client/Http2.php index 89aa1f8b..31ada537 100644 --- a/HttpServer/Client/Http2.php +++ b/HttpServer/Client/Http2.php @@ -10,6 +10,7 @@ use ReflectionException; use Snowflake\Abstracts\Component; use Snowflake\Core\Help; use Snowflake\Core\Json; +use Snowflake\Core\Xml; use Snowflake\Exception\ComponentException; use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; @@ -137,7 +138,14 @@ class Http2 extends Component if ($response->statusCode > 200) { throw new Exception($client->errMsg, $response->statusCode); } - return Help::toArray($response->data); + $header = $response->headers['content-type']; + if (str_starts_with($header, 'application/json;')) { + return Json::decode($response->data); + } else if (str_starts_with($header, 'application/xml;')) { + return Xml::toArray($response->data); + } else { + return $response->data; + } }