add clear
This commit is contained in:
+14
-13
@@ -680,21 +680,22 @@ class HttpClient
|
|||||||
if ($this->method == self::POST) {
|
if ($this->method == self::POST) {
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
} else {
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($this->method != self::GET && !empty($this->_data)) {
|
||||||
|
$this->_data = $this->mergeParams($data);
|
||||||
|
}
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($this->method));
|
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') {
|
||||||
|
$this->_data = json_encode($this->_data, JSON_UNESCAPED_UNICODE);
|
||||||
|
} else {
|
||||||
|
$this->_data = http_build_query($this->_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_data);
|
||||||
|
|
||||||
$output = curl_exec($ch);
|
$output = curl_exec($ch);
|
||||||
if ($output === false) {
|
if ($output === false) {
|
||||||
throw new Exception(curl_error($ch));
|
throw new Exception(curl_error($ch));
|
||||||
|
|||||||
Reference in New Issue
Block a user