[Patch] HTTP::absoluteURI() port redundancy
| From: | Turadg Aleahmad | Date: | Fri, 10 Sep 2004 00:51:06 +0000 |
| Subject: | [Patch] HTTP::absoluteURI() port redundancy | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-33325@lists.php.net to get a copy of this message | ||
This is a simple patch to eliminate the redundant port field of absolute URIs when it's already implied by the protocol. If given a relative URL like /myfile it will change it to http://$SERVER_NAME:$SERVER_PORT even if the port is 80. I use HTTP::redirect() on my site, which makes use of absoluteURI(), and Safari users have reported that they see the :80 in their URLs. This isn't merely aesthetic; it confuses many users.
The patch below checks if the port is already implied by the protocol and omits it if so.
diff HTTP.php-in-cvs HTTP.php-that-I-edited
285a286,288
if ($protocol == 'http' && $port == 80) unset($port);
if ($protocol == 'https' && $port == 443) unset($port);
Note, this sounds similar but is different from Bug #1040.
-Turadg