From baf07b7ab23e84e8ee212ef2e03a08cf0688f224 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Thu, 9 Jan 2020 18:57:08 +0800 Subject: [PATCH] add clear --- common/Help.php | 8 ++++++++ common/HttpClient.php | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/Help.php b/common/Help.php index 74ece6c..77bb785 100644 --- a/common/Help.php +++ b/common/Help.php @@ -41,6 +41,9 @@ class Help extends Miniprogarampage if (is_array($json)) { return $json; } + if (!static::isXml($json)) { + return $json; + } $data = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); if (is_array($data)) { return $data; @@ -49,6 +52,11 @@ class Help extends Miniprogarampage } + public static function isXml($body) + { + return preg_match('/^<[a-zA-Z_]+>(.*?)?<\/[a-zA-Z_]+>$/', $body); + } + /** * @param int $length * @return string diff --git a/common/HttpClient.php b/common/HttpClient.php index 2e363ae..15043fc 100644 --- a/common/HttpClient.php +++ b/common/HttpClient.php @@ -528,9 +528,6 @@ class HttpClient return $body; } $type = $data['content-type']; - if ($this->isXml($body)) { - return Help::toArray($body); - } if (strpos($type, 'text/html') !== false) { return $body; } else if (strpos($type, 'json') !== false) { @@ -543,11 +540,6 @@ class HttpClient return $body; } - private function isXml($body) - { - return preg_match('/^<[a-zA-Z_]+>(.*?)?<\/[a-zA-Z_]+>$/', $body); - } - /** * @param $headers * @return array