protected function addCredentials(array $headers)
    {

        if (!$this->user || !$this->password) {
            return $headers;
        }

        // Check if credentials are already in headers
        foreach ($headers as $line) {
            if (stripos(trim($line),'authorization: basic') === 0) {
                return $headers;
            }
        }

        $auth = $this->user . ':' . $this->password;

        $headers[] = 'Authorization: Basic ' . base64_encode("$auth");

        return $headers;

    }