Skip to content

Commit

Permalink
API client class v1.1.67
Browse files Browse the repository at this point in the history
- fixed a bug where the request headers for subsequent function calls within the same Client instance would not always be cleared
  • Loading branch information
malle-pietje committed Jan 24, 2021
1 parent aa778c9 commit caf838a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @package UniFi_Controller_API_Client_Class
* @author Art of WiFi <info@artofwifi.net>
* @version Release: 1.1.66
* @version Release: 1.1.67
* @license This class is subject to the MIT license that is bundled with this package in the file LICENSE.md
* @example This directory in the package repository contains a collection of examples:
* https://github.com/Art-of-WiFi/UniFi-API-client/tree/master/examples
Expand All @@ -22,7 +22,7 @@ class Client
/**
* private and protected properties
*/
private $class_version = '1.1.66';
private $class_version = '1.1.67';
protected $baseurl = 'https://127.0.0.1:8443';
protected $user = '';
protected $password = '';
Expand Down Expand Up @@ -3071,7 +3071,7 @@ public function cmd_stat($command)
}

/**
* Toggle Element Adoption ON or OFF
* Toggle Element Adoption ON or OFF
*
* @param bool $enable true enables Element Adoption, false disables Element Adoption
* @return bool true on success
Expand Down Expand Up @@ -3759,7 +3759,8 @@ protected function exec_curl($path, $payload = null)
return false;
}

$json_payload = '';
$this->headers = [];
$json_payload = '';

if ($this->is_unifi_os) {
$url = $this->baseurl . '/proxy/network' . $path;
Expand All @@ -3777,12 +3778,11 @@ protected function exec_curl($path, $payload = null)
/**
* what we do when a payload is passed
*/
if (!is_null($payload)) {
if (!empty($payload)) {
$json_payload = json_encode($payload, JSON_UNESCAPED_SLASHES);
$curl_options[CURLOPT_POST] = true;
$curl_options[CURLOPT_POSTFIELDS] = $json_payload;

$this->headers = [
$this->headers[] = [
'content-type: application/json',
'content-length: ' . strlen($json_payload)
];
Expand Down

0 comments on commit caf838a

Please sign in to comment.