add clear

This commit is contained in:
2020-11-25 16:47:43 +08:00
parent b92fdeee39
commit 8e1d54413a
+8
View File
@@ -681,6 +681,14 @@ class HttpClient
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
} }
if ($this->method == self::GET || !empty($this->_data)) { if ($this->method == self::GET || !empty($this->_data)) {
if (!is_string($this->_data)) {
$message = $this->header['Content-Type'] ?? $this->header['content-type'] ?? 'application/json';
if ($message == 'application/json') {
$this->_data = json_encode($this->_data, JSON_UNESCAPED_UNICODE);
} else {
$this->_data = http_build_query($this->_data);
}
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_data); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_data);
} else { } else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data)); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data));