add clear
This commit is contained in:
@@ -41,6 +41,9 @@ class Help extends Miniprogarampage
|
|||||||
if (is_array($json)) {
|
if (is_array($json)) {
|
||||||
return $json;
|
return $json;
|
||||||
}
|
}
|
||||||
|
if (!static::isXml($json)) {
|
||||||
|
return $json;
|
||||||
|
}
|
||||||
$data = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
$data = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
return $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
|
* @param int $length
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@@ -528,9 +528,6 @@ class HttpClient
|
|||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
$type = $data['content-type'];
|
$type = $data['content-type'];
|
||||||
if ($this->isXml($body)) {
|
|
||||||
return Help::toArray($body);
|
|
||||||
}
|
|
||||||
if (strpos($type, 'text/html') !== false) {
|
if (strpos($type, 'text/html') !== false) {
|
||||||
return $body;
|
return $body;
|
||||||
} else if (strpos($type, 'json') !== false) {
|
} else if (strpos($type, 'json') !== false) {
|
||||||
@@ -543,11 +540,6 @@ class HttpClient
|
|||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isXml($body)
|
|
||||||
{
|
|
||||||
return preg_match('/^<[a-zA-Z_]+>(.*?)?<\/[a-zA-Z_]+>$/', $body);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $headers
|
* @param $headers
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
Reference in New Issue
Block a user