cvs: pear /Net_URL URL.php

From: Date: Wed, 19 Jun 2002 23:15:44 +0000
Subject: cvs: pear /Net_URL URL.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4696@lists.php.net to get a copy of this message
richard Wed Jun 19 19:15:44 2002 EDT Modified files: /pear/Net_URL URL.php Log: * Use Host: header instead of SERVER_NAME if available Index: pear/Net_URL/URL.php diff -u pear/Net_URL/URL.php:1.12 pear/Net_URL/URL.php:1.13 --- pear/Net_URL/URL.php:1.12 Wed May 29 17:42:48 2002 +++ pear/Net_URL/URL.php Wed Jun 19 19:15:43 2002 @@ -15,7 +15,7 @@ // | Author: Richard Heyes <richard@phpguru.org> | // +----------------------------------------------------------------------+ // -// $Id: URL.php,v 1.12 2002/05/29 21:42:48 richard Exp $ +// $Id: URL.php,v 1.13 2002/06/19 23:15:43 richard Exp $ // // Net_URL Class // @@ -88,12 +88,24 @@ { global $HTTP_SERVER_VARS; + /** + * Figure out host/port + */ + if (!empty($HTTP_SERVER_VARS['HTTP_HOST']) AND preg_match('/^(.*)(:([0-9]+))?$/U', $HTTP_SERVER_VARS['HTTP_HOST'], $matches)) { + $host = $matches[1]; + if (!empty($matches[3])) { + $port = $matches[3]; + } else { + $port = '80'; + } + } + $this->url = $url; $this->protocol = 'http' . (@$HTTP_SERVER_VARS['HTTPS'] == 'on' ? 's' : ''); $this->user = ''; $this->pass = ''; - $this->host = isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost'; - $this->port = isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : 80; + $this->host = !empty($host) ? $host : (isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost'); + $this->port = !empty($port) ? $port : (isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : 80); $this->path = $HTTP_SERVER_VARS['PHP_SELF']; $this->querystring = $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']); $this->anchor = '';

« previous php.pear.cvs (#4696) next »