From ab2e7e3900308adc8fc18633324a5409316d6504 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Thu, 9 Jan 2020 18:55:30 +0800 Subject: [PATCH] add clear --- common/HttpClient.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/HttpClient.php b/common/HttpClient.php index 15043fc..2e363ae 100644 --- a/common/HttpClient.php +++ b/common/HttpClient.php @@ -528,6 +528,9 @@ 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) { @@ -540,6 +543,11 @@ class HttpClient return $body; } + private function isXml($body) + { + return preg_match('/^<[a-zA-Z_]+>(.*?)?<\/[a-zA-Z_]+>$/', $body); + } + /** * @param $headers * @return array