diff --git a/httpclient.php b/httpclient.php index 024bdf2..6601711 100644 --- a/httpclient.php +++ b/httpclient.php @@ -4,6 +4,8 @@ * @author Dominique Fournier */ +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. @@ -93,6 +95,10 @@ class Httpclient */ private $referer = ""; + /** The accept type of data wanted by the client + */ + private $accept = "text/html;q=0.9, */*;q=0.8"; + // }}} /** The constructor @@ -170,6 +176,15 @@ class Httpclient } // }}} + /** Get the headers sent to the server after the page was get + */ + public function headersSent () + // {{{ + { + return $this->headersSent; + } + // }}} + /** Get the port used for connection */ public function port () @@ -316,6 +331,19 @@ class Httpclient } // }}} + /** Get/Set the accept type of page wanted by the client + * @param string|null $accept The accept types with weight + */ + public function accept ($accept = null) + // {{{ + { + if ($accept === null) + return $this->accept; + $this->accept = $accept; + return $this; + } + // }}} + ////////////////////////////////// //// THE ACTIVE METHODS //// ////////////////////////////////// @@ -447,7 +475,8 @@ class Httpclient $this->headersSent = array (); $this->headersSent[] = "$this->method $path HTTP/1.1"; $this->headersSent[] = "Host: ".$parseURL["host"]; - $this->headersSent[] = "Accept: text/html;q=0.9, */*;q=0.8"; + if ($this->accept != "") + $this->headersSent[] = "Accept: $this->accept"; if ($this->useragent !== "") $this->headersSent[] = "User-Agent: $this->useragent"; if ($this->referer !== "") @@ -600,8 +629,8 @@ class Httpclient 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); + $this->log (1, "URL $this->method $this->url $this->httpCode $this->bodySize"); + // }}} } // }}}