add clear

This commit is contained in:
as2252258@163.com
2020-01-09 18:55:30 +08:00
parent 583630d0ca
commit ab2e7e3900
+8
View File
@@ -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