add clear

This commit is contained in:
2020-11-25 16:55:23 +08:00
parent 8e1d54413a
commit 07803dd31a
+6 -5
View File
@@ -680,7 +680,12 @@ class HttpClient
if ($this->method == self::POST) {
curl_setopt($ch, CURLOPT_POST, 1);
}
if ($this->method == self::GET || !empty($this->_data)) {
if ($this->method != self::GET && !empty($this->_data)) {
$this->_data = $this->mergeParams($data);
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($this->method));
if (!is_string($this->_data)) {
$message = $this->header['Content-Type'] ?? $this->header['content-type'] ?? 'application/json';
if ($message == 'application/json') {
@@ -690,11 +695,7 @@ class HttpClient
}
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_data);
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data));
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($this->method));
$output = curl_exec($ch);
if ($output === false) {
throw new Exception(curl_error($ch));