httpclient : update to bad methods parameters

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4800 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-12-26 07:36:59 +00:00
parent 4cea28e534
commit 2bdb73bac1

View File

@@ -4,8 +4,6 @@
* @author Dominique Fournier <dominique@fournier38.fr>
*/
namespace vendor\domframework;
/** This programe allow to get a HTTP page from a site, and examine the content.
* It will store the Cookies, allow to do the redirects, follow links and
* get form / input and send the values.
@@ -280,7 +278,7 @@ class Httpclient
* 30s by default
* @param integer|null $timeout The timeout value
*/
public function timeout ($timeout)
public function timeout ($timeout = null)
// {{{
{
if ($timeout === null)
@@ -294,7 +292,7 @@ class Httpclient
* sent
* @param string|null $useragent The user agent to use
*/
public function useragent ($useragent)
public function useragent ($useragent = null)
// {{{
{
if ($useragent === null)
@@ -308,7 +306,7 @@ class Httpclient
* @param string|null $referer The new referer that will be used on next
* request
*/
public function referer ($referer)
public function referer ($referer = null)
// {{{
{
if ($referer === null)
@@ -347,8 +345,8 @@ class Httpclient
throw new \Exception ("File to get exceeded maxsize", 500);
}
$this->disconnect ();
$this->referer = $url;
if ($this->httpCode === 301 || $this->httpCode === 302)
if ($this->httpCode === 301 || $this->httpCode === 302 ||
key_exists ("Location", $this->headersReceived))
{
if (! key_exists ("Location", $this->headersReceived))
throw new \Exception ("Redirect without location provided", 406);
@@ -369,6 +367,7 @@ class Httpclient
$this->log (1, "REDIRECT $this->httpCode to $location");
$content = $this->getPage ($location, $ssloptions);
}
$this->referer = $url;
$this->redirectCount = 0;
return $content;
}
@@ -382,6 +381,7 @@ class Httpclient
public function connect ($ssloptions = array ())
// {{{
{
$this->log (2, "## URL Start $this->method $this->url");
$this->headersReceived = array ();
$this->bodySize = null;
$this->httpCode = null;
@@ -442,7 +442,6 @@ class Httpclient
throw new \Exception ("No host provided to URL", 406);
// }}}
$this->log (1, "URL $this->method $this->url");
// Prepare the headers to be sent
// {{{
$this->headersSent = array ();
@@ -598,6 +597,11 @@ class Httpclient
{
throw new \Exception ("No transfert content provided", 500);
}
if ($this->contentMethod === "chunked")
$this->log (1, "URL $this->method $this->url $this->httpCode Chunked");
else
$this->log (1, "URL $this->method $this->url $this->httpCode $this->bodySize");
// }}}
}
// }}}