[Phphtmllib-devel] SF.net SVN: phphtmllib:[3320] trunk/phphtmllib/src/request/RequestBuilder. inc
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2010-01-12 19:14:58
|
Revision: 3320 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3320&view=rev Author: hemna Date: 2010-01-12 19:14:48 +0000 (Tue, 12 Jan 2010) Log Message: ----------- added support for automatic Port additions to the request url Modified Paths: -------------- trunk/phphtmllib/src/request/RequestBuilder.inc Modified: trunk/phphtmllib/src/request/RequestBuilder.inc =================================================================== --- trunk/phphtmllib/src/request/RequestBuilder.inc 2010-01-08 03:04:39 UTC (rev 3319) +++ trunk/phphtmllib/src/request/RequestBuilder.inc 2010-01-12 19:14:48 UTC (rev 3320) @@ -46,6 +46,20 @@ * @var string */ protected $var_separator = '&'; + + + /** + * Stores the server to connect to. + * If this isn't set, then we pull it + * from the $_REQUEST + * + */ + protected $server = null; + + /** + * the server port. + */ + protected $port = null; /** @@ -200,6 +214,30 @@ return $this->server; } + + + /** + * Set the port for the request. + * @param $port + */ + public function set_port($port) { + $this->port = $port; + } + + /** + * get the port for the request. + * + * @return int + */ + public function get_port() { + if (!$this->port) { + $this->port = $_SERVER["SERVER_PORT"]; + if ($this->port == 80) { + $this->port = null; + } + } + return $this->port; + } /** * This method builds the entire query string. @@ -283,7 +321,15 @@ //properly build the url if ($this->url_type == Request::URL_TYPE_ABSOLUTE) { //this is an absolute request. - $url = $this->get_protocol().$this->get_server().Request::SLASH.$this->get_file(); + $url = $this->get_protocol().$this->get_server(); + $port = $this->get_port(); + if ($port) { + $url .= ":".$port; + } + $file = $this->get_file(); + if ($file) { + $url .= Request::SLASH.$this->get_file(); + } if (($query = $this->get_query_string()) && $query != '?') { $url .= Request::SLASH.$this->get_query_string(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |