diff --git a/httpclient.php b/httpclient.php index 4f2d350..ba334ec 100644 --- a/httpclient.php +++ b/httpclient.php @@ -55,6 +55,10 @@ class Httpclient */ private $ssloptions = array (); + /** Authentication value + */ + private $authentication = ""; + /** The maximum maxsize allowed */ private $maxsize; @@ -436,8 +440,22 @@ class Httpclient public function authBasic ($login, $password) // {{{ { - $this->headersSent["Authorization"] = "Basic ". - base64_encode ("$login:$password"); + $this->authentication = "Basic ". base64_encode ("$login:$password"); + return $this; + } + // }}} + + /** Get/Set authentication + * To remove authentication, pass "" to $auth arg + * @param string|null $auth The authentication string to send + * @return value or $this + */ + public function authentication ($auth = null) + // {{{ + { + if ($auth === null) + return $this->authentication; + $this->authentication = $auth; return $this; } // }}} @@ -568,6 +586,8 @@ class Httpclient $this->headersSent["User-Agent"] = $this->useragent; if ($this->referer !== "") $this->headersSent["Referer"] = $this->referer; + if ($this->authentication !== "") + $this->headersSent["Authorization"] = $this->authentication; $this->headersSent["Connection"] = "keep-alive"; $cookies = $this->cookieToSend ($this->url); if (! empty ($cookies))