httpclient : add the authentication method and do not reset it between connections
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5319 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -55,6 +55,10 @@ class Httpclient
|
|||||||
*/
|
*/
|
||||||
private $ssloptions = array ();
|
private $ssloptions = array ();
|
||||||
|
|
||||||
|
/** Authentication value
|
||||||
|
*/
|
||||||
|
private $authentication = "";
|
||||||
|
|
||||||
/** The maximum maxsize allowed
|
/** The maximum maxsize allowed
|
||||||
*/
|
*/
|
||||||
private $maxsize;
|
private $maxsize;
|
||||||
@@ -436,8 +440,22 @@ class Httpclient
|
|||||||
public function authBasic ($login, $password)
|
public function authBasic ($login, $password)
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$this->headersSent["Authorization"] = "Basic ".
|
$this->authentication = "Basic ". base64_encode ("$login:$password");
|
||||||
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;
|
return $this;
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
@@ -568,6 +586,8 @@ class Httpclient
|
|||||||
$this->headersSent["User-Agent"] = $this->useragent;
|
$this->headersSent["User-Agent"] = $this->useragent;
|
||||||
if ($this->referer !== "")
|
if ($this->referer !== "")
|
||||||
$this->headersSent["Referer"] = $this->referer;
|
$this->headersSent["Referer"] = $this->referer;
|
||||||
|
if ($this->authentication !== "")
|
||||||
|
$this->headersSent["Authorization"] = $this->authentication;
|
||||||
$this->headersSent["Connection"] = "keep-alive";
|
$this->headersSent["Connection"] = "keep-alive";
|
||||||
$cookies = $this->cookieToSend ($this->url);
|
$cookies = $this->cookieToSend ($this->url);
|
||||||
if (! empty ($cookies))
|
if (! empty ($cookies))
|
||||||
|
|||||||
Reference in New Issue
Block a user