add clear

This commit is contained in:
2020-05-22 15:21:47 +08:00
parent 9c415292a4
commit 6c1c1a379b
+9 -5
View File
@@ -213,7 +213,7 @@ class HttpClient
*/
public function setHeader($key, $value)
{
$this->header[$key] = $value;
$this->header[strtoupper($key)] = $value;
}
/**
@@ -222,7 +222,7 @@ class HttpClient
*/
public function addHeader($key, $value)
{
$this->header[$key] = $value;
$this->header[strtoupper($key)] = $value;
}
/**
@@ -513,7 +513,6 @@ class HttpClient
}
if (!empty($this->_data)) {
var_dump($this->_data);
$client->setData($this->_data);
}
$client->execute($url);
@@ -554,7 +553,12 @@ class HttpClient
return $data;
}
}
$contentType = $this->header['Content-Type'] ?? 'application/x-www-form-urlencoded';
$contentType = 'application/x-www-form-urlencoded';
if (isset($this->header['CONTENT-TYPE'])) {
$contentType = $this->header['CONTENT-TYPE'];
}
if (strpos($contentType, 'json') !== false) {
return Help::toJson($data);
} else if (strpos($contentType, 'xml') !== false) {
@@ -941,7 +945,7 @@ class HttpClient
return [];
}
foreach ($headers as $key => $val) {
$this->header[$key] = $val;
$this->header[strtoupper($key)] = $val;
}
return $this->header;
}